* Return current line of text. Called by dialog_textbox() and print_line(). * 'page' should point to start of current line before calling, and will be * updated to point to start of next line. */
| 52 | * updated to point to start of next line. |
| 53 | */ |
| 54 | static char *get_line(void) |
| 55 | { |
| 56 | int i = 0; |
| 57 | static char line[MAX_LEN + 1]; |
| 58 | |
| 59 | end_reached = 0; |
| 60 | while (*page != '\n') { |
| 61 | if (*page == '\0') { |
| 62 | end_reached = 1; |
| 63 | break; |
| 64 | } else if (i < MAX_LEN) |
| 65 | line[i++] = *(page++); |
| 66 | else { |
| 67 | /* Truncate lines longer than MAX_LEN characters */ |
| 68 | if (i == MAX_LEN) |
| 69 | line[i++] = '\0'; |
| 70 | page++; |
| 71 | } |
| 72 | } |
| 73 | if (i <= MAX_LEN) |
| 74 | line[i] = '\0'; |
| 75 | if (!end_reached) |
| 76 | page++; /* move past '\n' */ |
| 77 | |
| 78 | return line; |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | * Print a new line of text. |
no outgoing calls
no test coverage detected