🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.c
Article #310383

uszkodzona tablica stringów

#310383
From: Robert magdziarz
Date: Thu, 28 Jul 2022 08:39
64 lines
4111 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].
Technical Details
Message-ID: <7967cbf7-d0a9-4792-b3f8-8f779b98097bn@googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.man.lodz.pl!newsfeed.pionier.net.pl!2.eu.feeder.erje.net!feeder.erje.net!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Received: by 2002:ac8:5f0f:0:b0:31f:3966:3f87 with SMTP id x15-20020ac85f0f000000b0031f39663f87mr14233873qta.578.1658997550419;        Thu, 28 Jul 2022 01:39:10 -0700 (PDT)
X-Received: by 2002:a05:620a:2414:b0:6b6:1382:e7b7 with SMTP id d20-20020a05620a241400b006b61382e7b7mr19540327qkn.490.1658997550249; Thu, 28 Jul 2022 01:39:10 -0700 (PDT)
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.man.lodz.pl!newsfeed.pionier.net.pl!2.eu.feeder.erje.net!feeder.erje.net!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: pl.comp.lang.c
Date: Thu, 28 Jul 2022 01:39:10 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2a01:110f:1505:4500:6d2a:2a5a:4a35:fd07; posting-account=JdKRlQoAAACyiQ-sNfmyLoKZN5Pl9aim
NNTP-Posting-Host: 2a01:110f:1505:4500:6d2a:2a5a:4a35:fd07
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7967cbf7-d0a9-4792-b3f8-8f779b98097bn@googlegroups.com>
Subject: uszkodzona tablica stringów
From: Robert magdziarz <rmagdziarz2022@gmail.com>
Injection-Date: Thu, 28 Jul 2022 08:39:10 +0000
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit