MCPcopy Create free account
hub / github.com/apache/nuttx / block_comment_width

Function block_comment_width

tools/nxstyle.c:987–1054  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

985 ********************************************************************************/
986
987static int block_comment_width(char *line)
988{
989 int b;
990 int e;
991 int n;
992
993 /* Skip over any leading whitespace on the line */
994
995 for (b = 0; isspace(line[b]); b++)
996 {
997 }
998
999 /* Skip over any trailing whitespace at the end of the line */
1000
1001 for (e = strlen(line) - 1; e >= 0 && isspace(line[e]); e--)
1002 {
1003 }
1004
1005 /* Number of characters on the line */
1006
1007 n = e - b + 1;
1008 if (n < 4)
1009 {
1010 return 0;
1011 }
1012
1013 /* The first line of a block comment starts with "[slash]***" and ends with
1014 * "***"
1015 */
1016
1017 if (strncmp(&line[b], "/***", 4) == 0 &&
1018 strncmp(&line[e - 2], "***", 3) == 0)
1019 {
1020 /* Return the the length of the line up to the final '*' */
1021
1022 return e + 1;
1023 }
1024
1025 /* The last line of a block begins with whitespace then "***" and ends
1026 * with "***[slash]"
1027 */
1028
1029 if (strncmp(&line[b], "***", 3) == 0 &&
1030 strncmp(&line[e - 3], "***/", 4) == 0)
1031 {
1032 /* Return the the length of the line up to the final '*' */
1033
1034 return e;
1035 }
1036
1037 /* But there is also a special single line comment that begins with "[slash]* "
1038 * and ends with "***[slash]"
1039 */
1040
1041 if (strncmp(&line[b], "/*", 2) == 0 &&
1042 strncmp(&line[e - 3], "***/", 4) == 0)
1043 {
1044 /* Return the the length of the line up to the final '*' */

Callers 1

get_line_widthFunction · 0.85

Calls 3

isspaceFunction · 0.50
strlenFunction · 0.50
strncmpFunction · 0.50

Tested by

no test coverage detected