* Return no. of columns in output window. * @param fp FILE * @return no. of columns */
| 94 | * @return no. of columns |
| 95 | */ |
| 96 | static size_t maxColumnWidth(FILE *fp) |
| 97 | { |
| 98 | size_t maxcols = _POPTHELP_MAXLINE; |
| 99 | #if defined(TIOCGWINSZ) |
| 100 | struct winsize ws; |
| 101 | int fdno = fileno(fp ? fp : stdout); |
| 102 | |
| 103 | memset(&ws, 0, sizeof(ws)); |
| 104 | if (fdno >= 0 && !ioctl(fdno, (unsigned long)TIOCGWINSZ, &ws)) { |
| 105 | size_t ws_col = (size_t)ws.ws_col; |
| 106 | if (ws_col > maxcols && ws_col < (size_t)256) |
| 107 | maxcols = ws_col - 1; |
| 108 | } |
| 109 | #endif |
| 110 | return maxcols; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Determine number of display characters in a string. |
no outgoing calls
no test coverage detected