Thread View: pl.comp.lang.c
4 messages
4 total messages
Started by Robert magdziarz
Thu, 28 Jul 2022 01:39
uszkodzona tablica stringów
Author: Robert magdziarz
Date: Thu, 28 Jul 2022 01:39
Date: Thu, 28 Jul 2022 01:39
73 lines
2871 bytes
2871 bytes
Mam obiekt klasy source_file: class source_file { private: std::wstring source_file_path; int current_source_line_no; bool inside_php, start_inside_php; int num_source_lines, too_long_line_number; std::vector<std::string> source_lines; std::vector<std::pair<int, std::string>> tokenized_lines; std::vector<std::pair<int, std::string>>::const_iterator current_tokenized_lines_iter; size_t max_line_len, too_long_line_len, max_found_line_len; public: source_file(size_t max_line_length = 0) { // 0 means 'no limit' max_line_len = max_line_length; too_long_line_len = 0; max_found_line_len = 0; current_source_line_no = -1; num_source_lines = 0; current_tokenized_lines_iter = tokenized_lines.end(); too_long_line_number = 0; inside_php = start_inside_php = false; } size_t get_max_found_line_length() const { return max_found_line_len; } size_t get_too_long_line_length() const { return too_long_line_len; } int get_too_long_line_number() const { return too_long_line_number; } bool open(std::wstring in_file_path); void close() { source_lines.clear(); tokenized_lines.clear(); too_long_line_len = 0; max_found_line_len = 0; num_source_lines = 0; current_source_line_no = -1; } void rewind() { // go to begin of file current_source_line_no = -1; current_tokenized_lines_iter = tokenized_lines.begin(); inside_php = start_inside_php = false; } bool get_next_line(std::string &line); bool change_current_line(std::string line, bool ltrim_line); void ltrim_current_line(); void get_contents(std::vector<std::string> &contents); bool change_file_with_contents(const std::vector<std::string> &contents, unsigned int defines_line_num = 0, unsigned int defines_num_lines = 0); void remove_magic_str(); // obejście dla problemu pozostających magic_str void write(std::wstring out_file_path) const { std::ofstream out_file(shortwstr2str(out_file_path)); for (std::string line : source_lines) { out_file << line << std::endl; } } void tokenize_file(std::string token_name_delim_str); bool get_next_line_with_tokenized(std::string &line, std::string &tokenized_line); }; Chociaż plik jest ładowany poprawnie przez metodę open, mam problem zepsutego stringu w source_lines[813], tzn. get_next_line() zwraca zepsuty string line. Nie znam momentu w którym source_lines[813] jest psute - używam VSCodium ale nie działają mi pułapki warunkowe. Proszę o pomoc: jak znaleźć miejsce w kodzie w którym psuty jest string source_lines[813].
Re: uszkodzona tablica stringów
Author: Robert magdziarz
Date: Thu, 28 Jul 2022 06:53
Date: Thu, 28 Jul 2022 06:53
3 lines
260 bytes
260 bytes
"zepsucie" polega na tym, że po open() mam: source_lines[813] z końcówką "Line}}}}}" a source_lines[814]=="EOL;", natomiast w get_next_line() mam: source_lines[813] z końcówką "LineEOL;" a source_lines[814]=="".
Re: uszkodzona tablica stringów
Author: Jivanmukta
Date: Fri, 29 Jul 2022 12:06
Date: Fri, 29 Jul 2022 12:06
9 lines
718 bytes
718 bytes
W dniu 28.07.2022 o 10:39, Robert magdziarz pisze: > Chociaż plik jest ładowany poprawnie przez metodę open, mam problem zepsutego stringu w source_lines[813], tzn. get_next_line() zwraca zepsuty string line. Nie znam momentu w którym source_lines[813] jest psute - używam VSCodium ale nie działają mi pułapki warunkowe. > Proszę o pomoc: jak znaleźć miejsce w kodzie w którym psuty jest string source_lines[813]. Pomiędzy wywołaniami open() i get_next_line() mam wywołania change_current_line() i tokenize_file(), ale te funkcję nie psują source_lines[], sprawdziłem. Czy w tej sytuacji jest możliwe, że tablica stringów source_lines[] jest jakoś zamazywana spoza metod klasy source_lines?
Re: uszkodzona tablica stringów
Author: Jivanmukta
Date: Fri, 29 Jul 2022 12:55
Date: Fri, 29 Jul 2022 12:55
16 lines
837 bytes
837 bytes
W dniu 29.07.2022 o 12:06, Jivanmukta pisze: > W dniu 28.07.2022 o 10:39, Robert magdziarz pisze: > >> Chociaż plik jest ładowany poprawnie przez metodę open, mam problem >> zepsutego stringu w source_lines[813], tzn. get_next_line() zwraca >> zepsuty string line. Nie znam momentu w którym source_lines[813] jest >> psute - używam VSCodium ale nie działają mi pułapki warunkowe. >> Proszę o pomoc: jak znaleźć miejsce w kodzie w którym psuty jest >> string source_lines[813]. > > Pomiędzy wywołaniami open() i get_next_line() mam wywołania > change_current_line() i tokenize_file(), ale te funkcję nie psują > source_lines[], sprawdziłem. > Czy w tej sytuacji jest możliwe, że tablica stringów source_lines[] jest > jakoś zamazywana spoza metod klasy source_lines? Pardon: spoza metod klasy source_file
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads