File indexing completed on 2024-03-24 04:38:43
0001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 0002 * 0003 * Copyright (C) 2006-2010 by Jim Pattee <jimp03@email.com> 0004 * Copyright (C) 1998-2002 by Tal Davidson 0005 * <http://www.gnu.org/licenses/lgpl-3.0.html> 0006 * 0007 * This file is a part of Artistic Style - an indentation and 0008 * reformatting tool for C, C++, C# and Java source files. 0009 * <http://astyle.sourceforge.net> 0010 * 0011 * Artistic Style is free software: you can redistribute it and/or modify 0012 * it under the terms of the GNU Lesser General Public License as published 0013 * by the Free Software Foundation, either version 3 of the License, or 0014 * (at your option) any later version. 0015 * 0016 * Artistic Style is distributed in the hope that it will be useful, 0017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0019 * GNU Lesser General Public License for more details. 0020 * 0021 * You should have received a copy of the GNU Lesser General Public License 0022 * along with Artistic Style. If not, see <http://www.gnu.org/licenses/>. 0023 * 0024 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 0025 */ 0026 0027 #include "astyle.h" 0028 #include <algorithm> 0029 0030 0031 namespace astyle 0032 { 0033 const string ASResource::AS_IF = string("if"); 0034 const string ASResource::AS_ELSE = string("else"); 0035 const string ASResource::AS_FOR = string("for"); 0036 const string ASResource::AS_DO = string("do"); 0037 const string ASResource::AS_WHILE = string("while"); 0038 const string ASResource::AS_SWITCH = string("switch"); 0039 const string ASResource::AS_CASE = string("case"); 0040 const string ASResource::AS_DEFAULT = string("default"); 0041 const string ASResource::AS_CLASS = string("class"); 0042 const string ASResource::AS_STRUCT = string("struct"); 0043 const string ASResource::AS_UNION = string("union"); 0044 const string ASResource::AS_INTERFACE = string("interface"); 0045 const string ASResource::AS_NAMESPACE = string("namespace"); 0046 const string ASResource::AS_EXTERN = string("extern"); 0047 const string ASResource::AS_ENUM = string("enum"); 0048 const string ASResource::AS_PUBLIC = string("public"); 0049 const string ASResource::AS_PROTECTED = string("protected"); 0050 const string ASResource::AS_PRIVATE = string("private"); 0051 const string ASResource::AS_STATIC = string("static"); 0052 const string ASResource::AS_SYNCHRONIZED = string("synchronized"); 0053 const string ASResource::AS_OPERATOR = string("operator"); 0054 const string ASResource::AS_TEMPLATE = string("template"); 0055 const string ASResource::AS_TRY = string("try"); 0056 const string ASResource::AS_CATCH = string("catch"); 0057 const string ASResource::AS_FINALLY = string("finally"); 0058 const string ASResource::AS_THROWS = string("throws"); 0059 const string ASResource::AS_CONST = string("const"); 0060 const string ASResource::AS_WHERE = string("where"); 0061 const string ASResource::AS_NEW = string("new"); 0062 0063 const string ASResource::AS_ASM = string("asm"); 0064 const string ASResource::AS__ASM__ = string("__asm__"); 0065 const string ASResource::AS_MS_ASM = string("_asm"); 0066 const string ASResource::AS_MS__ASM = string("__asm"); 0067 0068 const string ASResource::AS_BAR_DEFINE = string("#define"); 0069 const string ASResource::AS_BAR_INCLUDE = string("#include"); 0070 const string ASResource::AS_BAR_IF = string("#if"); 0071 const string ASResource::AS_BAR_EL = string("#el"); 0072 const string ASResource::AS_BAR_ENDIF = string("#endif"); 0073 0074 const string ASResource::AS_OPEN_BRACKET = string("{"); 0075 const string ASResource::AS_CLOSE_BRACKET = string("}"); 0076 const string ASResource::AS_OPEN_LINE_COMMENT = string("//"); 0077 const string ASResource::AS_OPEN_COMMENT = string("/*"); 0078 const string ASResource::AS_CLOSE_COMMENT = string("*/"); 0079 0080 const string ASResource::AS_ASSIGN = string("="); 0081 const string ASResource::AS_PLUS_ASSIGN = string("+="); 0082 const string ASResource::AS_MINUS_ASSIGN = string("-="); 0083 const string ASResource::AS_MULT_ASSIGN = string("*="); 0084 const string ASResource::AS_DIV_ASSIGN = string("/="); 0085 const string ASResource::AS_MOD_ASSIGN = string("%="); 0086 const string ASResource::AS_OR_ASSIGN = string("|="); 0087 const string ASResource::AS_AND_ASSIGN = string("&="); 0088 const string ASResource::AS_XOR_ASSIGN = string("^="); 0089 const string ASResource::AS_GR_GR_ASSIGN = string(">>="); 0090 const string ASResource::AS_LS_LS_ASSIGN = string("<<="); 0091 const string ASResource::AS_GR_GR_GR_ASSIGN = string(">>>="); 0092 const string ASResource::AS_LS_LS_LS_ASSIGN = string("<<<="); 0093 const string ASResource::AS_GCC_MIN_ASSIGN = string("<?"); 0094 const string ASResource::AS_GCC_MAX_ASSIGN = string(">?"); 0095 0096 const string ASResource::AS_RETURN = string("return"); 0097 const string ASResource::AS_CIN = string("cin"); 0098 const string ASResource::AS_COUT = string("cout"); 0099 const string ASResource::AS_CERR = string("cerr"); 0100 0101 const string ASResource::AS_EQUAL = string("=="); 0102 const string ASResource::AS_PLUS_PLUS = string("++"); 0103 const string ASResource::AS_MINUS_MINUS = string("--"); 0104 const string ASResource::AS_NOT_EQUAL = string("!="); 0105 const string ASResource::AS_GR_EQUAL = string(">="); 0106 const string ASResource::AS_GR_GR = string(">>"); 0107 const string ASResource::AS_GR_GR_GR = string(">>>"); 0108 const string ASResource::AS_LS_EQUAL = string("<="); 0109 const string ASResource::AS_LS_LS = string("<<"); 0110 const string ASResource::AS_LS_LS_LS = string("<<<"); 0111 const string ASResource::AS_QUESTION_QUESTION = string("??"); 0112 const string ASResource::AS_EQUAL_GR = string("=>"); // C# lambda expression arrow 0113 const string ASResource::AS_ARROW = string("->"); 0114 const string ASResource::AS_AND = string("&&"); 0115 const string ASResource::AS_OR = string("||"); 0116 const string ASResource::AS_COLON_COLON = string("::"); 0117 const string ASResource::AS_PAREN_PAREN = string("()"); 0118 const string ASResource::AS_BLPAREN_BLPAREN = string("[]"); 0119 0120 const string ASResource::AS_PLUS = string("+"); 0121 const string ASResource::AS_MINUS = string("-"); 0122 const string ASResource::AS_MULT = string("*"); 0123 const string ASResource::AS_DIV = string("/"); 0124 const string ASResource::AS_MOD = string("%"); 0125 const string ASResource::AS_GR = string(">"); 0126 const string ASResource::AS_LS = string("<"); 0127 const string ASResource::AS_NOT = string("!"); 0128 const string ASResource::AS_BIT_OR = string("|"); 0129 const string ASResource::AS_BIT_AND = string("&"); 0130 const string ASResource::AS_BIT_NOT = string("~"); 0131 const string ASResource::AS_BIT_XOR = string("^"); 0132 const string ASResource::AS_QUESTION = string("?"); 0133 const string ASResource::AS_COLON = string(":"); 0134 const string ASResource::AS_COMMA = string(","); 0135 const string ASResource::AS_SEMICOLON = string(";"); 0136 0137 const string ASResource::AS_FOREACH = string("foreach"); 0138 const string ASResource::AS_LOCK = string("lock"); 0139 const string ASResource::AS_UNSAFE = string("unsafe"); 0140 const string ASResource::AS_FIXED = string("fixed"); 0141 const string ASResource::AS_GET = string("get"); 0142 const string ASResource::AS_SET = string("set"); 0143 const string ASResource::AS_ADD = string("add"); 0144 const string ASResource::AS_REMOVE = string("remove"); 0145 const string ASResource::AS_DELEGATE = string("delegate"); 0146 const string ASResource::AS_UNCHECKED = string("unchecked"); 0147 0148 const string ASResource::AS_CONST_CAST = string("const_cast"); 0149 const string ASResource::AS_DYNAMIC_CAST = string("dynamic_cast"); 0150 const string ASResource::AS_REINTERPRET_CAST = string("reinterpret_cast"); 0151 const string ASResource::AS_STATIC_CAST = string("static_cast"); 0152 0153 0154 /** 0155 * Sort comparison function. 0156 * Compares the length of the value of pointers in the vectors. 0157 * The LONGEST strings will be first in the vector. 0158 * 0159 * @params the string pointers to be compared. 0160 */ 0161 bool sortOnLength(const string *a, const string *b) 0162 { 0163 return (*a).length() > (*b).length(); 0164 } 0165 0166 /** 0167 * Sort comparison function. 0168 * Compares the value of pointers in the vectors. 0169 * 0170 * @params the string pointers to be compared. 0171 */ 0172 bool sortOnName(const string *a, const string *b) 0173 { 0174 return *a < *b; 0175 } 0176 0177 /** 0178 * Build the vector of assignment operators. 0179 * Used by BOTH ASFormatter.cpp and ASBeautifier.cpp 0180 * 0181 * @param assignmentOperators a reference to the vector to be built. 0182 */ 0183 void ASResource::buildAssignmentOperators(vector<const string*>* assignmentOperators) 0184 { 0185 assignmentOperators->push_back(&AS_ASSIGN); 0186 assignmentOperators->push_back(&AS_PLUS_ASSIGN); 0187 assignmentOperators->push_back(&AS_MINUS_ASSIGN); 0188 assignmentOperators->push_back(&AS_MULT_ASSIGN); 0189 assignmentOperators->push_back(&AS_DIV_ASSIGN); 0190 assignmentOperators->push_back(&AS_MOD_ASSIGN); 0191 assignmentOperators->push_back(&AS_OR_ASSIGN); 0192 assignmentOperators->push_back(&AS_AND_ASSIGN); 0193 assignmentOperators->push_back(&AS_XOR_ASSIGN); 0194 0195 // Java 0196 assignmentOperators->push_back(&AS_GR_GR_GR_ASSIGN); 0197 assignmentOperators->push_back(&AS_GR_GR_ASSIGN); 0198 assignmentOperators->push_back(&AS_LS_LS_ASSIGN); 0199 0200 // Unknown 0201 assignmentOperators->push_back(&AS_LS_LS_LS_ASSIGN); 0202 0203 sort(assignmentOperators->begin(), assignmentOperators->end(), sortOnLength); 0204 } 0205 0206 /** 0207 * Build the vector of C++ cast operators. 0208 * Used by ONLY ASFormatter.cpp 0209 * 0210 * @param castOperators a reference to the vector to be built. 0211 */ 0212 void ASResource::buildCastOperators(vector<const string*>* castOperators) 0213 { 0214 castOperators->push_back(&AS_CONST_CAST); 0215 castOperators->push_back(&AS_DYNAMIC_CAST); 0216 castOperators->push_back(&AS_REINTERPRET_CAST); 0217 castOperators->push_back(&AS_STATIC_CAST); 0218 } 0219 0220 /** 0221 * Build the vector of header words. 0222 * Used by BOTH ASFormatter.cpp and ASBeautifier.cpp 0223 * 0224 * @param headers a reference to the vector to be built. 0225 */ 0226 void ASResource::buildHeaders(vector<const string*>* headers, int fileType, bool beautifier) 0227 { 0228 headers->push_back(&AS_IF); 0229 headers->push_back(&AS_ELSE); 0230 headers->push_back(&AS_FOR); 0231 headers->push_back(&AS_WHILE); 0232 headers->push_back(&AS_DO); 0233 headers->push_back(&AS_SWITCH); 0234 headers->push_back(&AS_TRY); 0235 headers->push_back(&AS_CATCH); 0236 0237 if (fileType == JAVA_TYPE) 0238 { 0239 headers->push_back(&AS_FINALLY); 0240 headers->push_back(&AS_SYNCHRONIZED); 0241 } 0242 0243 if (fileType == SHARP_TYPE) 0244 { 0245 headers->push_back(&AS_FINALLY); 0246 headers->push_back(&AS_FOREACH); 0247 headers->push_back(&AS_LOCK); 0248 // headers->push_back(&AS_UNSAFE); 0249 headers->push_back(&AS_FIXED); 0250 headers->push_back(&AS_GET); 0251 headers->push_back(&AS_SET); 0252 headers->push_back(&AS_ADD); 0253 headers->push_back(&AS_REMOVE); 0254 } 0255 0256 if (beautifier) 0257 { 0258 headers->push_back(&AS_CASE); 0259 headers->push_back(&AS_DEFAULT); 0260 0261 if (fileType == C_TYPE) 0262 { 0263 headers->push_back(&AS_CONST); 0264 headers->push_back(&AS_TEMPLATE); 0265 } 0266 0267 if (fileType == JAVA_TYPE) 0268 { 0269 headers->push_back(&AS_STATIC); // for static constructor 0270 } 0271 } 0272 sort(headers->begin(), headers->end(), sortOnName); 0273 } 0274 0275 /** 0276 * Build the vector of indentable headers. 0277 * Used by ONLY ASBeautifier.cpp 0278 * 0279 * @param indentableHeaders a reference to the vector to be built. 0280 */ 0281 void ASResource::buildIndentableHeaders(vector<const string*>* indentableHeaders) 0282 { 0283 indentableHeaders->push_back(&AS_RETURN); 0284 // indentableHeaders->push_back(&AS_COUT); 0285 // indentableHeaders->push_back(&AS_CERR); 0286 // indentableHeaders->push_back(&AS_CIN); 0287 0288 sort(indentableHeaders->begin(), indentableHeaders->end(), sortOnName); 0289 } 0290 0291 /** 0292 * Build the vector of non-assignment operators. 0293 * Used by ONLY ASBeautifier.cpp 0294 * 0295 * @param nonAssignmentOperators a reference to the vector to be built. 0296 */ 0297 void ASResource::buildNonAssignmentOperators(vector<const string*>* nonAssignmentOperators) 0298 { 0299 nonAssignmentOperators->push_back(&AS_EQUAL); 0300 nonAssignmentOperators->push_back(&AS_PLUS_PLUS); 0301 nonAssignmentOperators->push_back(&AS_MINUS_MINUS); 0302 nonAssignmentOperators->push_back(&AS_NOT_EQUAL); 0303 nonAssignmentOperators->push_back(&AS_GR_EQUAL); 0304 nonAssignmentOperators->push_back(&AS_GR_GR_GR); 0305 nonAssignmentOperators->push_back(&AS_GR_GR); 0306 nonAssignmentOperators->push_back(&AS_LS_EQUAL); 0307 nonAssignmentOperators->push_back(&AS_LS_LS_LS); 0308 nonAssignmentOperators->push_back(&AS_LS_LS); 0309 nonAssignmentOperators->push_back(&AS_ARROW); 0310 nonAssignmentOperators->push_back(&AS_AND); 0311 nonAssignmentOperators->push_back(&AS_OR); 0312 0313 sort(nonAssignmentOperators->begin(), nonAssignmentOperators->end(), sortOnLength); 0314 } 0315 0316 /** 0317 * Build the vector of header non-paren headers. 0318 * Used by BOTH ASFormatter.cpp and ASBeautifier.cpp 0319 * 0320 * @param nonParenHeaders a reference to the vector to be built. 0321 */ 0322 void ASResource::buildNonParenHeaders(vector<const string*>* nonParenHeaders, int fileType, bool beautifier) 0323 { 0324 nonParenHeaders->push_back(&AS_ELSE); 0325 nonParenHeaders->push_back(&AS_DO); 0326 nonParenHeaders->push_back(&AS_TRY); 0327 0328 if (fileType == JAVA_TYPE) 0329 { 0330 nonParenHeaders->push_back(&AS_FINALLY); 0331 } 0332 0333 if (fileType == SHARP_TYPE) 0334 { 0335 nonParenHeaders->push_back(&AS_CATCH); // can be a paren or non-paren header 0336 nonParenHeaders->push_back(&AS_FINALLY); 0337 // nonParenHeaders->push_back(&AS_UNSAFE); 0338 nonParenHeaders->push_back(&AS_GET); 0339 nonParenHeaders->push_back(&AS_SET); 0340 nonParenHeaders->push_back(&AS_ADD); 0341 nonParenHeaders->push_back(&AS_REMOVE); 0342 } 0343 0344 if (beautifier) 0345 { 0346 nonParenHeaders->push_back(&AS_CASE); 0347 nonParenHeaders->push_back(&AS_DEFAULT); 0348 if (fileType == C_TYPE) 0349 { 0350 nonParenHeaders->push_back(&AS_CONST); 0351 nonParenHeaders->push_back(&AS_TEMPLATE); 0352 } 0353 if (fileType == JAVA_TYPE) 0354 { 0355 nonParenHeaders->push_back(&AS_STATIC); 0356 } 0357 } 0358 sort(nonParenHeaders->begin(), nonParenHeaders->end(), sortOnName); 0359 } 0360 0361 /** 0362 * Build the vector of operators. 0363 * Used by ONLY ASFormatter.cpp 0364 * 0365 * @param operators a reference to the vector to be built. 0366 */ 0367 void ASResource::buildOperators(vector<const string*>* operators) 0368 { 0369 operators->push_back(&AS_PLUS_ASSIGN); 0370 operators->push_back(&AS_MINUS_ASSIGN); 0371 operators->push_back(&AS_MULT_ASSIGN); 0372 operators->push_back(&AS_DIV_ASSIGN); 0373 operators->push_back(&AS_MOD_ASSIGN); 0374 operators->push_back(&AS_OR_ASSIGN); 0375 operators->push_back(&AS_AND_ASSIGN); 0376 operators->push_back(&AS_XOR_ASSIGN); 0377 operators->push_back(&AS_EQUAL); 0378 operators->push_back(&AS_PLUS_PLUS); 0379 operators->push_back(&AS_MINUS_MINUS); 0380 operators->push_back(&AS_NOT_EQUAL); 0381 operators->push_back(&AS_GR_EQUAL); 0382 operators->push_back(&AS_GR_GR_GR_ASSIGN); 0383 operators->push_back(&AS_GR_GR_ASSIGN); 0384 operators->push_back(&AS_GR_GR_GR); 0385 operators->push_back(&AS_GR_GR); 0386 operators->push_back(&AS_LS_EQUAL); 0387 operators->push_back(&AS_LS_LS_LS_ASSIGN); 0388 operators->push_back(&AS_LS_LS_ASSIGN); 0389 operators->push_back(&AS_LS_LS_LS); 0390 operators->push_back(&AS_LS_LS); 0391 operators->push_back(&AS_QUESTION_QUESTION); 0392 operators->push_back(&AS_EQUAL_GR); 0393 operators->push_back(&AS_GCC_MIN_ASSIGN); 0394 operators->push_back(&AS_GCC_MAX_ASSIGN); 0395 operators->push_back(&AS_ARROW); 0396 operators->push_back(&AS_AND); 0397 operators->push_back(&AS_OR); 0398 operators->push_back(&AS_COLON_COLON); 0399 operators->push_back(&AS_PLUS); 0400 operators->push_back(&AS_MINUS); 0401 operators->push_back(&AS_MULT); 0402 operators->push_back(&AS_DIV); 0403 operators->push_back(&AS_MOD); 0404 operators->push_back(&AS_QUESTION); 0405 operators->push_back(&AS_COLON); 0406 operators->push_back(&AS_ASSIGN); 0407 operators->push_back(&AS_LS); 0408 operators->push_back(&AS_GR); 0409 operators->push_back(&AS_NOT); 0410 operators->push_back(&AS_BIT_OR); 0411 operators->push_back(&AS_BIT_AND); 0412 operators->push_back(&AS_BIT_NOT); 0413 operators->push_back(&AS_BIT_XOR); 0414 0415 sort(operators->begin(), operators->end(), sortOnLength); 0416 } 0417 0418 /** 0419 * Build the vector of pre-block statements. 0420 * Used by ONLY ASBeautifier.cpp 0421 * NOTE: Cannot be both a header and a preBlockStatement. 0422 * 0423 * @param preBlockStatements a reference to the vector to be built. 0424 */ 0425 void ASResource::buildPreBlockStatements(vector<const string*>* preBlockStatements, int fileType) 0426 { 0427 preBlockStatements->push_back(&AS_CLASS); 0428 if (fileType == C_TYPE) 0429 { 0430 preBlockStatements->push_back(&AS_STRUCT); 0431 preBlockStatements->push_back(&AS_UNION); 0432 preBlockStatements->push_back(&AS_NAMESPACE); 0433 } 0434 if (fileType == JAVA_TYPE) 0435 { 0436 preBlockStatements->push_back(&AS_INTERFACE); 0437 preBlockStatements->push_back(&AS_THROWS); 0438 } 0439 if (fileType == SHARP_TYPE) 0440 { 0441 preBlockStatements->push_back(&AS_INTERFACE); 0442 preBlockStatements->push_back(&AS_NAMESPACE); 0443 preBlockStatements->push_back(&AS_WHERE); 0444 preBlockStatements->push_back(&AS_STRUCT); 0445 } 0446 sort(preBlockStatements->begin(), preBlockStatements->end(), sortOnName); 0447 } 0448 0449 /** 0450 * Build the vector of pre-command headers. 0451 * Used by ONLY ASFormatter.cpp 0452 * 0453 * @param preCommandHeaders a reference to the vector to be built. 0454 */ 0455 void ASResource::buildPreCommandHeaders(vector<const string*>* preCommandHeaders, int fileType) 0456 { 0457 if (fileType == C_TYPE) 0458 { 0459 preCommandHeaders->push_back(&AS_CONST); 0460 } 0461 0462 if (fileType == JAVA_TYPE) 0463 { 0464 preCommandHeaders->push_back(&AS_THROWS); 0465 } 0466 0467 if (fileType == SHARP_TYPE) 0468 { 0469 preCommandHeaders->push_back(&AS_WHERE); 0470 } 0471 0472 sort(preCommandHeaders->begin(), preCommandHeaders->end(), sortOnName); 0473 } 0474 0475 /** 0476 * Build the vector of pre-definition headers. 0477 * Used by ONLY ASFormatter.cpp 0478 * NOTE: Do NOT add 'enum' here. It is an array type bracket. 0479 * NOTE: Do NOT add 'extern' here. Do not want an extra indent. 0480 * 0481 * @param preDefinitionHeaders a reference to the vector to be built. 0482 */ 0483 void ASResource::buildPreDefinitionHeaders(vector<const string*>* preDefinitionHeaders, int fileType) 0484 { 0485 preDefinitionHeaders->push_back(&AS_CLASS); 0486 if (fileType == C_TYPE) 0487 { 0488 preDefinitionHeaders->push_back(&AS_STRUCT); 0489 preDefinitionHeaders->push_back(&AS_UNION); 0490 preDefinitionHeaders->push_back(&AS_NAMESPACE); 0491 } 0492 if (fileType == JAVA_TYPE) 0493 { 0494 preDefinitionHeaders->push_back(&AS_INTERFACE); 0495 } 0496 if (fileType == SHARP_TYPE) 0497 { 0498 preDefinitionHeaders->push_back(&AS_STRUCT); 0499 preDefinitionHeaders->push_back(&AS_INTERFACE); 0500 preDefinitionHeaders->push_back(&AS_NAMESPACE); 0501 } 0502 sort(preDefinitionHeaders->begin(), preDefinitionHeaders->end(), sortOnName); 0503 } 0504 0505 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 0506 * ASBase Funtions 0507 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 0508 0509 // check if a specific line position contains a keyword. 0510 bool ASBase::findKeyword(const string &line, int i, const string &keyword) const 0511 { 0512 assert(isCharPotentialHeader(line, i)); 0513 // check the word 0514 const size_t keywordLength = keyword.length(); 0515 const size_t wordEnd = i + keywordLength; 0516 if (wordEnd > line.length()) 0517 return false; 0518 if (line.compare(i, keywordLength, keyword) != 0) 0519 return false; 0520 // check that this is not part of a longer word 0521 if (wordEnd == line.length()) 0522 return true; 0523 if (isLegalNameChar(line[wordEnd])) 0524 return false; 0525 // is not a keyword if part of a definition 0526 const char peekChar = peekNextChar(line, wordEnd - 1); 0527 if (peekChar == ',' || peekChar == ')') 0528 return false; 0529 return true; 0530 } 0531 0532 // get the current word on a line 0533 // index must point to the beginning of the word 0534 string ASBase::getCurrentWord(const string& line, size_t index) const 0535 { 0536 assert(isCharPotentialHeader(line, index)); 0537 size_t lineLength = line.length(); 0538 size_t i; 0539 for (i = index; i < lineLength; i++) 0540 { 0541 if (!isLegalNameChar(line[i])) 0542 break; 0543 } 0544 return line.substr(index, i - index); 0545 } 0546 0547 } // end namespace astyle