Return the state to use for the string starting at i; *nextIndex will be set to the first index following the quote(s) */
| 43 | |
| 44 | /* Return the state to use for the string starting at i; *nextIndex will be set to the first index following the quote(s) */ |
| 45 | static int GetPyStringState(Accessor &styler, int i, unsigned int *nextIndex) { |
| 46 | char ch = styler.SafeGetCharAt(i); |
| 47 | char chNext = styler.SafeGetCharAt(i + 1); |
| 48 | |
| 49 | // Advance beyond r, u, or ur prefix, but bail if there are any unexpected chars |
| 50 | if (ch == 'r' || ch == 'R') { |
| 51 | i++; |
| 52 | ch = styler.SafeGetCharAt(i); |
| 53 | chNext = styler.SafeGetCharAt(i + 1); |
| 54 | } else if (ch == 'u' || ch == 'U') { |
| 55 | if (chNext == 'r' || chNext == 'R') |
| 56 | i += 2; |
| 57 | else |
| 58 | i += 1; |
| 59 | ch = styler.SafeGetCharAt(i); |
| 60 | chNext = styler.SafeGetCharAt(i + 1); |
| 61 | } |
| 62 | |
| 63 | if (ch != '"' && ch != '\'') { |
| 64 | *nextIndex = i + 1; |
| 65 | return SCE_P_DEFAULT; |
| 66 | } |
| 67 | |
| 68 | if (ch == chNext && ch == styler.SafeGetCharAt(i + 2)) { |
| 69 | *nextIndex = i + 3; |
| 70 | |
| 71 | if (ch == '"') |
| 72 | return SCE_P_TRIPLEDOUBLE; |
| 73 | else |
| 74 | return SCE_P_TRIPLE; |
| 75 | } else { |
| 76 | *nextIndex = i + 1; |
| 77 | |
| 78 | if (ch == '"') |
| 79 | return SCE_P_STRING; |
| 80 | else |
| 81 | return SCE_P_CHARACTER; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | static inline bool IsAWordChar(int ch) { |
| 86 | return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_'); |
no test coverage detected