Skip to content

Conversation

trevtravtrev
Copy link

…s while using color mode.

- This fixes a major application breaking untraceable error (Large prompts crashing with no error output antimatter15#122)
- Tested and working
@HCBlackFox
Copy link

Nice, this is works!

@michieal
Copy link

michieal commented Apr 4, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants