| 150 | } |
| 151 | |
| 152 | staticfn void |
| 153 | vpline(const char *line, va_list the_args) |
| 154 | { |
| 155 | static int in_pline = 0; |
| 156 | char pbuf[BIGBUFSZ]; /* will get chopped down to BUFSZ-1 if longer */ |
| 157 | int ln; |
| 158 | int msgtyp; |
| 159 | boolean no_repeat; |
| 160 | coord a11y_mesgxy; |
| 161 | |
| 162 | a11y_mesgxy = a11y.msg_loc; /* save a11y.msg_loc before reseting it */ |
| 163 | /* always reset a11y.msg_loc whether we end up using it or not */ |
| 164 | a11y.msg_loc.x = a11y.msg_loc.y = 0; |
| 165 | |
| 166 | if (!line || !*line) |
| 167 | return; |
| 168 | #ifdef HANGUPHANDLING |
| 169 | if (program_state.done_hup) |
| 170 | return; |
| 171 | #endif |
| 172 | if (program_state.wizkit_wishing) |
| 173 | return; |
| 174 | |
| 175 | /* when accessiblemsg is set and a11y.msg_loc is nonzero, use the latter |
| 176 | to insert a location prefix in front of current message */ |
| 177 | if (a11y.accessiblemsg && isok(a11y_mesgxy.x, a11y_mesgxy.y)) { |
| 178 | char *tmp, *dirstr, dirstrbuf[QBUFSZ]; |
| 179 | |
| 180 | dirstr = coord_desc(a11y_mesgxy.x, a11y_mesgxy.y, dirstrbuf, |
| 181 | ((iflags.getpos_coords == GPCOORDS_NONE) |
| 182 | ? GPCOORDS_COMFULL : iflags.getpos_coords)); |
| 183 | tmp = (char *) alloc(strlen(line) + sizeof ": " + strlen(dirstr)); |
| 184 | Strcpy(tmp, dirstr); |
| 185 | Strcat(tmp, ": "); |
| 186 | Strcat(tmp, line); |
| 187 | vpline(tmp, the_args); |
| 188 | free((genericptr_t) tmp); |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | if (!strchr(line, '%')) { |
| 193 | /* format does not specify any substitutions; use it as-is */ |
| 194 | ln = (int) strlen(line); |
| 195 | } else if (line[0] == '%' && line[1] == 's' && !line[2]) { |
| 196 | /* "%s" => single string; skip format and use its first argument; |
| 197 | unlike with the format, it is irrelevant whether the argument |
| 198 | contains any percent signs */ |
| 199 | line = va_arg(the_args, const char *); /*VA_NEXT(line,const char *);*/ |
| 200 | ln = (int) strlen(line); |
| 201 | } else { |
| 202 | /* perform printf() formatting */ |
| 203 | ln = vsnprintf(pbuf, sizeof pbuf, line, the_args); |
| 204 | line = pbuf; |
| 205 | /* note: 'ln' is number of characters attempted, not necessarily |
| 206 | strlen(line); that matters for the overflow check; if we avoid |
| 207 | the extremely-too-long panic then 'ln' will be actual length */ |
| 208 | } |
| 209 | if (ln > (int) sizeof pbuf - 1) /* extremely too long */ |
no test coverage detected