alpaca.cpp
alpaca.cpp copied to clipboard
Fixes issue of medium to large prompts causing crashing with no errors while using color mode.
- This fixes a major application breaking untraceable error (Large prompts crashing with no error output #122)
- Tested and working
Nice, this is works!
if I may, what about doing something like this?
// Remove Magic Number, and make a #define:
#define INPUT_BUFFER_SIZE 16384
...
char buf[INPUT_BUFFER_SIZE] = {0};
int n_read;
if(params.use_color) printf(ANSI_BOLD ANSI_COLOR_GREEN);
std::string scan_line = std::string ("%") + std::to_string(INPUT_BUFFER_SIZE - 1) + "[^\n]%n%*c";
if (scanf(scan_line.c_str(), buf, &n_read) <= 0) {
// presumable empty line, consume the newline
if (scanf("%*c") <= 0) { /*ignore*/ }
n_read=0;
}
Mind you, I am really rusty on CPP... so, I am using Alpaca.cpp to get back into programming in c/cpp... That said, I think that this will work, and moves where one changes the input buf[] size to the top of the file.