| 5210 | #endif /* HANGUPHANDLING */ |
| 5211 | |
| 5212 | staticfn char |
| 5213 | readchar_core(coordxy *x, coordxy *y, int *mod) |
| 5214 | { |
| 5215 | int sym; |
| 5216 | |
| 5217 | if (iflags.debug_fuzzer) { |
| 5218 | sym = randomkey(); |
| 5219 | goto readchar_done; |
| 5220 | } |
| 5221 | if (*readchar_queue) |
| 5222 | sym = *readchar_queue++; |
| 5223 | else if (gi.in_doagain) |
| 5224 | sym = pgetchar(); |
| 5225 | else |
| 5226 | sym = nh_poskey(x, y, mod); |
| 5227 | |
| 5228 | #ifdef NR_OF_EOFS |
| 5229 | if (sym == EOF) { |
| 5230 | int cnt = NR_OF_EOFS; |
| 5231 | /* |
| 5232 | * Some SYSV systems seem to return EOFs for various reasons |
| 5233 | * (?like when one hits break or for interrupted systemcalls?), |
| 5234 | * and we must see several before we quit. |
| 5235 | */ |
| 5236 | do { |
| 5237 | clearerr(stdin); /* omit if clearerr is undefined */ |
| 5238 | sym = pgetchar(); |
| 5239 | } while (--cnt && sym == EOF); |
| 5240 | } |
| 5241 | #endif /* NR_OF_EOFS */ |
| 5242 | |
| 5243 | if (sym == EOF) { |
| 5244 | #ifdef HANGUPHANDLING |
| 5245 | hangup(0); /* call end_of_input() or set program_state.done_hup */ |
| 5246 | #endif |
| 5247 | sym = '\033'; |
| 5248 | #ifdef ALTMETA |
| 5249 | } else if (sym == '\033' && iflags.altmeta |
| 5250 | && program_state.input_state != otherInp) { |
| 5251 | /* iflags.altmeta: treat two character ``ESC c'' as single `M-c' but |
| 5252 | only when we're called by parse() [possibly via get_count()] |
| 5253 | or getpos() [to support Alt+digit] or getdir() [for arrow keys |
| 5254 | under curses] */ |
| 5255 | sym = *readchar_queue ? *readchar_queue++ : pgetchar(); |
| 5256 | if (sym == EOF || sym == 0) |
| 5257 | sym = '\033'; |
| 5258 | else if (sym != '\033') |
| 5259 | sym |= 0200; /* force 8th bit on */ |
| 5260 | #endif /*ALTMETA*/ |
| 5261 | } else if (sym == 0) { |
| 5262 | /* click event */ |
| 5263 | gc.clicklook_cc.x = gc.clicklook_cc.y = -1; |
| 5264 | click_to_cmd(*x, *y, *mod); |
| 5265 | } |
| 5266 | |
| 5267 | readchar_done: |
| 5268 | /* next readchar() will be for an ordinary char unless parse() |
| 5269 | sets this back to non-zero */ |
no test coverage detected