| 368 | } |
| 369 | |
| 370 | Status ValidateFunctionDescription(const std::string& s) { |
| 371 | if (!s.empty() && s.back() == '\n') { |
| 372 | return Status::Invalid("description ends with a newline"); |
| 373 | } |
| 374 | constexpr int kMaxLineSize = 78; |
| 375 | int cur_line_size = 0; |
| 376 | for (const auto c : s) { |
| 377 | cur_line_size = (c == '\n') ? 0 : cur_line_size + 1; |
| 378 | if (cur_line_size > kMaxLineSize) { |
| 379 | return Status::Invalid("description line length exceeds ", kMaxLineSize, |
| 380 | " characters"); |
| 381 | } |
| 382 | } |
| 383 | return Status::OK(); |
| 384 | } |
| 385 | |
| 386 | } // namespace |
| 387 | |