Patch level : 2.2
Files correlati : Ricompilazione Demo : [ ] Commento : Gestione dell'attributo Read-Only anche negli spreadsheet. Eliminato file regexp.* dal progetto delle librerie Corretta gestione filtri nelle ricerche per descrizione git-svn-id: svn://10.65.10.50/trunk@13410 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
a8e9b6c2d1
commit
ed343ffe04
@ -1107,7 +1107,13 @@ void TControl::set_rjust(bool on)
|
||||
// @doc INTERNAL
|
||||
|
||||
// @mfunc Flag di sola lettura
|
||||
void TControl::read_only(bool on)
|
||||
bool TControl::read_only() const
|
||||
{
|
||||
return (xi_get_attrib(_obj) & XI_ATR_READONLY) != 0;
|
||||
}
|
||||
|
||||
// @mfunc Flag di sola lettura
|
||||
void TControl::set_read_only(bool on)
|
||||
{
|
||||
change_attrib(XI_ATR_READONLY, on);
|
||||
}
|
||||
@ -1344,7 +1350,7 @@ void TField_control::create(WINDOW win, short cid,
|
||||
void TField_control::show_button(bool on)
|
||||
{
|
||||
XI_FIELD_DATA* f = _obj->v.field;
|
||||
bool has_button = f->button != 0;
|
||||
const bool has_button = f->button != 0;
|
||||
if (has_button != on)
|
||||
{
|
||||
f->button = on;
|
||||
@ -1352,16 +1358,6 @@ void TField_control::show_button(bool on)
|
||||
}
|
||||
}
|
||||
|
||||
bool TField_control::read_only() const
|
||||
{
|
||||
return bool((xi_get_attrib(_obj) & XI_ATR_READONLY) != 0);
|
||||
}
|
||||
|
||||
void TField_control::set_read_only(bool on)
|
||||
{
|
||||
change_attrib(XI_ATR_READONLY, on);
|
||||
}
|
||||
|
||||
bool TField_control::event_handler(XI_OBJ* itf, XI_EVENT* xiev)
|
||||
{
|
||||
if (in_create)
|
||||
|
@ -101,8 +101,8 @@ public:
|
||||
|
||||
virtual void destroy();
|
||||
|
||||
virtual void read_only(bool on = TRUE);
|
||||
|
||||
virtual bool read_only() const;
|
||||
virtual void set_read_only(bool on = TRUE);
|
||||
|
||||
virtual void set_rjust(bool on = TRUE);
|
||||
void set_ljust() { set_rjust(FALSE); }
|
||||
@ -164,10 +164,7 @@ public:
|
||||
void show_button(bool on);
|
||||
|
||||
// @cmember Forza il focus al controllo
|
||||
virtual void set_focus() const;
|
||||
|
||||
bool read_only() const;
|
||||
void set_read_only(bool on = TRUE);
|
||||
virtual void set_focus() const;
|
||||
void set_back_color(COLOR col);
|
||||
|
||||
// @cmember Costruttore
|
||||
|
@ -443,7 +443,7 @@ void TExpression::eval()
|
||||
{
|
||||
const TString & s2 = evalstack.pop_string();
|
||||
const TString & s1 = evalstack.pop_string();
|
||||
evalstack.push(s1.match(s2));
|
||||
evalstack.push(s1.match(s2, true)); // Match ignoring case
|
||||
}
|
||||
break;
|
||||
case _noteq:
|
||||
|
106
include/mask.cpp
106
include/mask.cpp
@ -187,29 +187,33 @@ void TMask::read_mask(
|
||||
{
|
||||
_total_time = clock()-start_t;
|
||||
|
||||
TFilename prof;
|
||||
make_profile_name(prof);
|
||||
TString16 para(user()); para << "_Locks";
|
||||
TConfig ini(prof, para);
|
||||
const int items = fields();
|
||||
TBit_array read_only(items);
|
||||
TAuto_token_string fields(ini.get("Lock"));
|
||||
|
||||
if (fields == "*")
|
||||
read_only.set();
|
||||
else
|
||||
set_locking(read_only, fields);
|
||||
|
||||
fields = ini.get("Unlock");
|
||||
set_locking(read_only, fields, false);
|
||||
TFilename prof;
|
||||
if (make_profile_name(prof))
|
||||
{
|
||||
TString16 para(user()); para << "_Locks";
|
||||
TConfig ini(prof, para);
|
||||
TAuto_token_string str = ini.get("Lock");
|
||||
if (!str.empty_items())
|
||||
{
|
||||
const int items = fields();
|
||||
TBit_array read_only(items); // Crea un opportuno array di bit
|
||||
|
||||
if (str == "*")
|
||||
read_only.set();
|
||||
else
|
||||
set_locking(read_only, str, true);
|
||||
str = ini.get("Unlock");
|
||||
if (!str.empty_items())
|
||||
set_locking(read_only, str, false);
|
||||
|
||||
for (int j = 0; j < items; j++)
|
||||
{
|
||||
TMask_field & f = fld(j);
|
||||
|
||||
if (read_only[j] && f.is_editable())
|
||||
f.set_read_only(true);
|
||||
}
|
||||
for (int j = 0; j < items; j++) if (read_only[j])
|
||||
{
|
||||
TMask_field& f = fld(j);
|
||||
if (f.is_editable() || f.is_sheet())
|
||||
f.set_read_only(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2110,12 +2114,13 @@ void TMask::copy_values(
|
||||
}
|
||||
}
|
||||
|
||||
void TMask::make_profile_name(TFilename& f) const
|
||||
bool TMask::make_profile_name(TFilename& f) const
|
||||
{
|
||||
f =::firm2dir(-1); // Directory dati
|
||||
f.add("config"); // Directory config
|
||||
f.add(source_file().name()); // Nome Maschera
|
||||
f.ext("ini"); // Estensione
|
||||
return f.exist();
|
||||
}
|
||||
|
||||
int TMask::save_profile(int num, const char* desc) const
|
||||
@ -2185,37 +2190,38 @@ int TMask::save_profile(int num, const char* desc) const
|
||||
int TMask::load_profile(int num, bool reset)
|
||||
{
|
||||
TFilename prof;
|
||||
make_profile_name(prof);
|
||||
|
||||
TConfig ini(prof, "Main");
|
||||
if (num <= 0)
|
||||
num = ini.get_int(user());
|
||||
else
|
||||
ini.set(user(), num);
|
||||
|
||||
TString16 name; name << num;
|
||||
TAssoc_array& var = ini.list_variables(name);
|
||||
|
||||
for (int pos = fields()-1; pos >= 0; pos--)
|
||||
if (make_profile_name(prof))
|
||||
{
|
||||
TMask_field& f = fld(pos);
|
||||
if (f.is_loadable() && f.get_default().empty())
|
||||
TConfig ini(prof, "Main");
|
||||
if (num <= 0)
|
||||
num = ini.get_int(user());
|
||||
else
|
||||
ini.set(user(), num);
|
||||
|
||||
TString16 name; name << num;
|
||||
TAssoc_array& var = ini.list_variables(name);
|
||||
|
||||
for (int pos = fields()-1; pos >= 0; pos--)
|
||||
{
|
||||
name.format("F_%d", f.dlg());
|
||||
if (reset || var.objptr(name) != NULL)
|
||||
TMask_field& f = fld(pos);
|
||||
if (f.is_loadable() && f.get_default().empty())
|
||||
{
|
||||
if (f.is_sheet())
|
||||
name.format("F_%d", f.dlg());
|
||||
if (reset || var.objptr(name) != NULL)
|
||||
{
|
||||
TSheet_field& sf = (TSheet_field&)f;
|
||||
sf.destroy();
|
||||
for (int r = 0; ini.exist(name,r); r++)
|
||||
sf.row(r) = ini.get(name, NULL, r);
|
||||
sf.force_update();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!f.is_firm())
|
||||
f.set(ini.get(name));
|
||||
if (f.is_sheet())
|
||||
{
|
||||
TSheet_field& sf = (TSheet_field&)f;
|
||||
sf.destroy();
|
||||
for (int r = 0; ini.exist(name,r); r++)
|
||||
sf.row(r) = ini.get(name, NULL, r);
|
||||
sf.force_update();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!f.is_firm())
|
||||
f.set(ini.get(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ public:
|
||||
void copy_values(const TMask &m);
|
||||
|
||||
// @cmember Crea il nome del file dei profili in <p f>
|
||||
void make_profile_name(TFilename& f) const;
|
||||
bool make_profile_name(TFilename& f) const;
|
||||
// @cmember Salva il profilo <p num>
|
||||
int save_profile(int num = 0, const char* desc = NULL) const;
|
||||
// @cmember Carica il profilo <p num>
|
||||
|
@ -208,7 +208,7 @@ void TMask_field::set_read_only(bool r)
|
||||
{
|
||||
_flags.read_only = r && !in_key(1);
|
||||
if (_ctl)
|
||||
_ctl->read_only(_flags.read_only);
|
||||
_ctl->set_read_only(_flags.read_only);
|
||||
}
|
||||
|
||||
// @doc INTERNAL
|
||||
|
@ -187,6 +187,7 @@ class TSpreadsheet : public TControl
|
||||
protected:
|
||||
//@cmember Gestisce gli eventi delle celle (chiamata dal <mf TSpreadsheet::xiev_handler>)
|
||||
virtual bool event_handler(XI_OBJ* itf, XI_EVENT* xiev);
|
||||
virtual void set_read_only(bool ro);
|
||||
|
||||
KEY barcode_newline() const;
|
||||
|
||||
@ -1038,7 +1039,6 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
|
||||
BOOLEAN& refused = xiev->refused;
|
||||
|
||||
|
||||
switch (xiev->type)
|
||||
{
|
||||
case XIE_GET_FIRST:
|
||||
@ -1212,7 +1212,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
{
|
||||
if (xiev->v.xi_obj->type == XIT_LIST) // Bottone dello sheet
|
||||
{
|
||||
if (test_focus_change())
|
||||
if (test_focus_change() && active())
|
||||
{
|
||||
int rec = -1;
|
||||
_cell_dirty = FALSE;
|
||||
@ -1304,7 +1304,6 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
||||
}
|
||||
}
|
||||
_check_enabled = TRUE;
|
||||
|
||||
}
|
||||
break;
|
||||
case XIE_DBL_CELL:
|
||||
@ -2378,7 +2377,6 @@ void TSpreadsheet::str2mask(int riga)
|
||||
}
|
||||
|
||||
TToken_string& r = row(riga);
|
||||
|
||||
owner().row2mask(riga, r);
|
||||
}
|
||||
|
||||
@ -2400,7 +2398,6 @@ KEY TSpreadsheet::edit(int n)
|
||||
{
|
||||
str2mask(n);
|
||||
KEY k = owner().run_editmask(n);
|
||||
|
||||
if (active())
|
||||
{
|
||||
if (k == K_ENTER)
|
||||
@ -2428,10 +2425,17 @@ KEY TSpreadsheet::edit(int n)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
k = K_ESC;
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
void TSpreadsheet::set_read_only(bool on)
|
||||
{
|
||||
activate(!on);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSheet_field
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -2734,7 +2738,6 @@ bool TSheet_field::row_enabled(int row)
|
||||
return (s->find_enabled_column(row,1,1) != 0);
|
||||
}
|
||||
|
||||
|
||||
void TSheet_field::enable_cell(int row, int column, bool on)
|
||||
{
|
||||
TSpreadsheet* s = (TSpreadsheet*)_ctl;
|
||||
@ -2747,7 +2750,6 @@ void TSheet_field::enable_column(int column, bool on)
|
||||
s->enable_column(column, on);
|
||||
}
|
||||
|
||||
|
||||
bool TSheet_field::column_enabled(int column) const
|
||||
{
|
||||
TSpreadsheet* s = (TSpreadsheet*)_ctl;
|
||||
@ -2839,8 +2841,6 @@ static int default_rows_compare(TSheet_field &s, int i, int j)
|
||||
return s1.compare(s2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TSheet_field::sort(ROWS_COMPARE_FUNCTION compare)
|
||||
{
|
||||
if (compare == NULL) compare = default_rows_compare;
|
||||
@ -2915,7 +2915,6 @@ bool TSheet_field::on_hit()
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
void TSheet_field::select(int r, bool scrollto)
|
||||
{
|
||||
TSpreadsheet* s = (TSpreadsheet*)_ctl;
|
||||
@ -3078,6 +3077,12 @@ void TSheet_field::row2mask(int n, TToken_string& r, int mode)
|
||||
m.set_caption(val);
|
||||
}
|
||||
|
||||
KEY TSheet_field::run_editmask(int )
|
||||
{
|
||||
TMask& m = sheet_mask();
|
||||
return m.run();
|
||||
}
|
||||
|
||||
void TSheet_field::set_back_and_fore_color(COLOR back, COLOR fore, int row, int col)
|
||||
{
|
||||
TSpreadsheet& s = (TSpreadsheet&)*_ctl;
|
||||
|
@ -182,7 +182,7 @@ public:
|
||||
// @cmember Ritorna la maschera corrispondente ad una riga dello spreadsheet
|
||||
virtual TMask& sheet_mask() const;
|
||||
// @cmember esegue la maschera di edit dello speadsheet;
|
||||
virtual KEY run_editmask(int ) { return sheet_mask().run();}
|
||||
virtual KEY run_editmask(int n);
|
||||
// @cmember Setta il membro <p _notify> della classe <c TSpreadsheet>
|
||||
void set_notify(SPREADSHEET_NOTIFY n);
|
||||
|
||||
|
@ -1,208 +0,0 @@
|
||||
#include <regexp.h>
|
||||
|
||||
/*
|
||||
#include <stdtypes.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
// codici di ritorno della matche()
|
||||
#define regexp_MATCH_PATTERN (6) // pattern non valido
|
||||
#define regexp_MATCH_LITERAL (5) // il pattern non coincide su un carattere comune
|
||||
#define regexp_MATCH_RANGE (4) // il pattern non coincide in un costrutto [..]
|
||||
#define regexp_MATCH_ABORT (3) // il stringa da confrontare è terminata anticipatamente
|
||||
#define regexp_MATCH_END (2) // il pattern è terminato anticipatamente
|
||||
#define regexp_MATCH_VALID (1) // pattern e stringa coincidono
|
||||
|
||||
// codici di ritorno della is_valid_pattern()
|
||||
#define regexp_PATTERN_VALID (0) // il pattern è valido
|
||||
#define regexp_PATTERN_ESC (-1) // è presente un escape aperto a fine pattern
|
||||
#define regexp_PATTERN_RANGE (-2) // c'è un range non chiuso all'interno di un costrutto [..]
|
||||
#define regexp_PATTERN_CLOSE (-3) // manca la parentesi di chiusura in un costrutto [..]
|
||||
#define regexp_PATTERN_EMPTY (-4) // c'è un costrutto vuoto
|
||||
|
||||
// prototipi delle funzioni interne
|
||||
HIDDEN int matche(const char *pat, const char *str); // ritorna un codice della classe regexp_MATCH che indica se e in che modo pattern e stringa coincidono
|
||||
HIDDEN int matche_after_star(const char *pat, const char *str); // chiama ricorsivamente la matche() con i segmenti puri del pattern e della stringa
|
||||
HIDDEN bool is_pattern(const char *pat); // ritorna TRUE se la stringa è un pattern
|
||||
HIDDEN bool is_valid_pattern(const char *pat, int *err= NULL); // ritorna TRUE se la stringa è un pattern valido, indica un codice di ritorno della classe regexp_PATTERN nel secondo parametro
|
||||
|
||||
HIDDEN bool is_pattern(const char *p) {
|
||||
while (*p) {
|
||||
switch (*p++) {
|
||||
case '?':
|
||||
case '*':
|
||||
case '[':
|
||||
case '\\':
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HIDDEN bool is_valid_pattern(const char *p, int *error_type) {
|
||||
if (error_type != NULL) *error_type= regexp_PATTERN_VALID; // inizializzazione del tipo d'errore
|
||||
while (*p) { // ciclo all'interno del pattern fino a fine stringa
|
||||
switch(*p) { // determinazione del tipo di wild card nel pattern
|
||||
case '\\': // controllo dell'escape, non può essere a fine pattern
|
||||
if (!*++p) {
|
||||
if (error_type != NULL) *error_type= regexp_PATTERN_ESC;
|
||||
return FALSE;
|
||||
}
|
||||
p++;
|
||||
break;
|
||||
case '[': // controllo della costruzione del costrutto [..]
|
||||
p++;
|
||||
if (*p == ']') { // se il prossimo carattere è ']' il costrutto è vuoto
|
||||
if (error_type != NULL) *error_type= regexp_PATTERN_EMPTY;
|
||||
return FALSE;
|
||||
}
|
||||
if (!*p) { // se si è a fine stringa il costrutto non è chiuso
|
||||
if (error_type != NULL) *error_type= regexp_PATTERN_CLOSE;
|
||||
return FALSE;
|
||||
}
|
||||
while (*p != ']') { // ciclo fino a fine costrutto [..]
|
||||
if (*p == '\\') { // controllo per gli escape
|
||||
p++;
|
||||
if (!*p++) { // controllo che l'escape non sia a fine pattern
|
||||
if (error_type != NULL) *error_type= regexp_PATTERN_ESC;
|
||||
return FALSE;
|
||||
}
|
||||
} else p++;
|
||||
if (!*p) { // se si è a fine stringa il costrutto non è chiuso
|
||||
if (error_type != NULL) *error_type= regexp_PATTERN_CLOSE;
|
||||
return FALSE;
|
||||
}
|
||||
if (*p == '-') { // controllo di un eventuale range
|
||||
if (!*++p || *p == ']') { // deve esistere una fine del range
|
||||
if (error_type != NULL) *error_type= regexp_PATTERN_RANGE;
|
||||
return FALSE;
|
||||
} else {
|
||||
if (*p == '\\') p++; // controllo degli escape
|
||||
if (!*p++) { // controllo che l'escape non sia a fine pattern
|
||||
if (error_type != NULL) *error_type= regexp_PATTERN_ESC;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '*': // tutti gli altri caratteri sono elementi validi del pattern
|
||||
case '?':
|
||||
default:
|
||||
p++; // caratteri normali
|
||||
break;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HIDDEN int matche_after_star(const char *p, const char *t) {
|
||||
int match= 0;
|
||||
while (*p == '?' || *p == '*') { // salto degli eventuali '*' e '?'
|
||||
if (*p == '?') // salto di un carattere per ciascun '?'
|
||||
if (!*t++) return regexp_MATCH_ABORT; // se la stringa termina qui non c'è coincidenza
|
||||
p++; // posizionamento sul prossimo carattere del pattern
|
||||
}
|
||||
if (!*p) return regexp_MATCH_VALID; //se il pattern è concluso c'è coincidenza
|
||||
int nextp= *p; // prelevamento del prossimo carattere, normale o '['
|
||||
if (nextp == '\\') {
|
||||
nextp= p[1];
|
||||
if (!nextp) return regexp_MATCH_PATTERN; // se il pattern termina qui non è valido
|
||||
}
|
||||
do { // ciclo fino a conclusione di stringa o pattern
|
||||
if (nextp == *t || nextp == '[') match= matche(p, t); // è necessario che il carattere corrente del testo coincida con il carattere corrente del pattern, oppure che il pattern abbia un inizio di costrutto [..]
|
||||
if (!*t++) match= regexp_MATCH_ABORT; // se la stringa termina qui non c'è coincidenza
|
||||
} while (match != regexp_MATCH_VALID && match != regexp_MATCH_ABORT && match != regexp_MATCH_PATTERN);
|
||||
return match; // ritorno del risultato
|
||||
}
|
||||
|
||||
HIDDEN int matche(const char *p, const char *t) {
|
||||
for (; *p; p++, t++) {
|
||||
if (!*t) // se si è alla fine della stringa, il confronto è concluso
|
||||
return (*p == '*' && *++p == '\0') ? regexp_MATCH_VALID : regexp_MATCH_ABORT;
|
||||
switch (*p) { // determina il tipo di wild card del pattern
|
||||
case '?': // carattere singolo, qualunque carattere coincide
|
||||
break;
|
||||
case '*': // sottostringa, coincide qualunque sequenza di caratteri
|
||||
return matche_after_star (p, t);
|
||||
case '[': { // costrutto [..], controllo di coincidenza per inclusione o esclusione su un solo carattere
|
||||
p++; // posizionamento all'inizio del range
|
||||
bool invert= FALSE; // controllo di inclusione o esclusione del costrutto
|
||||
if (*p == '!' || *p == '^') {
|
||||
invert= TRUE;
|
||||
p++;
|
||||
}
|
||||
if (*p == ']') // se si è su una chiusura di costrutto il pattern non è valido
|
||||
return regexp_MATCH_PATTERN;
|
||||
bool member_match= FALSE;
|
||||
bool loop= TRUE;
|
||||
while (loop) {
|
||||
char range_start, range_end; // inizio e fine del range corrente
|
||||
if (*p == ']') { // se si è alla fine del costrutto il ciclo si conclude
|
||||
loop= FALSE;
|
||||
continue;
|
||||
}
|
||||
if (*p == '\\') // controllo di coincidenza su un metacarattere, dopo un escape
|
||||
range_start= range_end= *++p;
|
||||
else
|
||||
range_start= range_end= *p;
|
||||
if (!*p) return regexp_MATCH_PATTERN; // se il pattern termina non è valido
|
||||
if (*++p == '-') { // controllo del segno di sottoinsieme
|
||||
range_end= *++p; // impostazione della fine del range
|
||||
if (range_end == '\0' || range_end == ']') return regexp_MATCH_PATTERN; // se il costrutto [..] o il pattern terminano qui allora il pattern non è valido
|
||||
if (range_end == '\\') { // la fine del range è un metacarattere
|
||||
range_end= *++p;
|
||||
if (!range_end) return regexp_MATCH_PATTERN; // se il pattern termina non è valido
|
||||
}
|
||||
p++; // posizionamento oltre il range
|
||||
}
|
||||
if (range_start < range_end) { // confronto del carattere corrente con il costrutto, controllo della sequenzialità degli estremi del range
|
||||
if (*t >= range_start && *t <= range_end) {
|
||||
member_match= TRUE;
|
||||
loop= FALSE;
|
||||
}
|
||||
} else {
|
||||
if (*t >= range_end && *t <= range_start) {
|
||||
member_match= TRUE;
|
||||
loop= FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((invert && member_match) || !(invert || member_match)) // controllo del risultato dell'ultimo confronto nel costrutto [..]
|
||||
return regexp_MATCH_RANGE;
|
||||
if (member_match) { // salto del resto del costrutto se non è esclusivo
|
||||
while (*p != ']') {
|
||||
if (!*p) return regexp_MATCH_PATTERN; // se si è a fine pattern il costrutto non è valido
|
||||
if (*p == '\\') { // salto di un confronto con un metacarattere
|
||||
p++;
|
||||
if (!*p) return regexp_MATCH_PATTERN; // se il pattern termina qui non è valido
|
||||
}
|
||||
p++; // posizionamento sul prossimo carattere del pattern
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case '\\': // confronto con un metacarattere
|
||||
p++; // posizionamento sul carattere da confrontare
|
||||
if (!*p) return regexp_MATCH_PATTERN; // se il pattern termina qui non è valido
|
||||
default: // confronto con un carattere normale
|
||||
if (*p != *t) return regexp_MATCH_LITERAL;
|
||||
}
|
||||
}
|
||||
if (*t) return regexp_MATCH_END; // se la stringa non è conclusa non c'è coincidenza
|
||||
else return regexp_MATCH_VALID;
|
||||
}
|
||||
|
||||
bool match(const char *pat, const char *str)
|
||||
{
|
||||
int err= matche(pat, str);
|
||||
return (err == regexp_MATCH_VALID); // ritorna TRUE se il pattern e la stringa coincidono
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
#include <xvt.h>
|
||||
|
||||
bool match(const char *pat, const char *str)
|
||||
{
|
||||
return xvt_str_match(str, pat, TRUE) != 0;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
#ifndef __REGEXP_H
|
||||
#define __REGEXP_H
|
||||
|
||||
// Composizione delle regular expression:
|
||||
// -------------------------------------
|
||||
// - '*' sostituisce una qualunque sottostringa (0 o più caratteri)
|
||||
// - '?' sostituisce un carattere qualunque (necessariamente presente)
|
||||
// - [RANGE] sostituisce un carattere presente nel RANGE specificato
|
||||
// I range si compongono di singoli caratteri o di sottoinsiemi di caratteri,
|
||||
// indicati con un carattere iniziale, un segno meno ('-') e un carattere
|
||||
// finale. Esempio [0-9a-fL] comprende i caratteri dallo '0' al '9', dalla 'a'
|
||||
// alla 'z' e la lettera 'L'. I range possono essere prefissati da '!' o
|
||||
// '^' per indicare che l'insieme dei caratteri specificati sono esclusi
|
||||
// e non inclusi. Esempio [!jkwxy] indica la sostituzione di qualunque
|
||||
// carattere tranne 'j', 'k', 'w', 'x', 'y' e 'z'.
|
||||
// Per specificare nei pattern gli stessi metacaratteri con cui si formano i
|
||||
// pattern basta prefissarli con l'escape '\'. Esempio [\[\]] sostituisce un
|
||||
// carattere di parentesi quadra aperta o chiusa.
|
||||
|
||||
bool match(const char *pat, const char *str); // ritorna TRUE se il pattern (primo parametro) e la stringa (secondo) coincidono
|
||||
|
||||
#endif
|
@ -154,7 +154,7 @@ void TScanner::push(const char* s)
|
||||
// @rdesc Ritorna TRUE se il paragrafo esiste
|
||||
bool TScanner::paragraph(const char* name)
|
||||
{
|
||||
TString p = name;
|
||||
TString256 p = name;
|
||||
if (p[0] != '[')
|
||||
{
|
||||
p.insert("[", 0);
|
||||
@ -164,7 +164,10 @@ bool TScanner::paragraph(const char* name)
|
||||
clear();// resetta eof
|
||||
seekg(0L);
|
||||
while (line().not_empty())
|
||||
if (token() == p) return TRUE;
|
||||
{
|
||||
if (token() == p)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1445,7 +1445,7 @@ HIDDEN TBrowse_sheet* _cur_browse = NULL;
|
||||
|
||||
void TBrowse_sheet::add_custom_filter(const char* regexp)
|
||||
{
|
||||
TString filter = _original_filter;
|
||||
TString filter = _original_filter; // Costruisco il nuovo filtro per estensione del vecchio
|
||||
if (regexp && *regexp)
|
||||
{
|
||||
if (_original_filter.not_empty())
|
||||
@ -1457,12 +1457,12 @@ void TBrowse_sheet::add_custom_filter(const char* regexp)
|
||||
if (_original_filter.not_empty())
|
||||
filter << ')';
|
||||
}
|
||||
if (filter != cursor()->filter())
|
||||
if (filter != cursor()->filter()) // Cambio il filtro se necessarion :-)
|
||||
{
|
||||
TCursor& c = *cursor();
|
||||
c.freeze(false);
|
||||
c.setfilter(filter, true);
|
||||
c.items();
|
||||
c.items(); // Forzo la ricostruzione del cursore
|
||||
c.freeze(true);
|
||||
|
||||
// Forzo un aggiornamento a basso livello
|
||||
@ -1560,7 +1560,7 @@ bool TBrowse_sheet::filter_handler(TMask_field& f, KEY k)
|
||||
const int pos = ids.get_pos(id);
|
||||
if (pos >= 0)
|
||||
{
|
||||
TToken_string fns = b.get_output_field_names();
|
||||
TToken_string fns = b.get_input_field_names();
|
||||
expr << fns.get(pos) << "?=\"" << e << '"';
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <dongle.h>
|
||||
#include <prefix.h>
|
||||
#include <real.h>
|
||||
#include <regexp.h>
|
||||
#include <utility.h>
|
||||
|
||||
// @doc EXTERNAL
|
||||
@ -48,7 +47,7 @@ inline bool is_space(char c)
|
||||
// @mfunc Cambia la dimensione della stringa eventualmente preservandone il contenuto iniziale
|
||||
void TString::resize(
|
||||
int size, // @parm Nuova dimensione della stringa
|
||||
bool cpy) // @parm Se TRUE mantiene il contenuto della stringa e alloca
|
||||
bool cpy) // @parm Se true mantiene il contenuto della stringa e alloca
|
||||
// nuovo spazio
|
||||
|
||||
// @comm Non funziona con le stringhe static e per valori negativi di <p size>
|
||||
@ -78,13 +77,13 @@ TString& TString::set(
|
||||
if (s && *s)
|
||||
{
|
||||
const int sz = strlen(s);
|
||||
if (sz > size()) resize(sz, FALSE);
|
||||
if (sz > size()) resize(sz, false);
|
||||
strcpy(_str, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (size() == 0)
|
||||
resize(DEFAULT_SIZE, FALSE);
|
||||
resize(DEFAULT_SIZE, false);
|
||||
*_str = '\0';
|
||||
}
|
||||
|
||||
@ -111,7 +110,7 @@ int TString::make_room(
|
||||
new_size = MAX_SIZE;
|
||||
if (new_size < min_size)
|
||||
fatal_box("Stringa di lunghezza eccessiva (%ld)", min_size);
|
||||
resize(int(new_size), TRUE);
|
||||
resize(int(new_size), true);
|
||||
}
|
||||
return lun;
|
||||
}
|
||||
@ -127,11 +126,11 @@ TString::TString(int size, char c) : _str(NULL), _size(0)
|
||||
if (size > 0)
|
||||
fill(c, size); // Guy: Much simpler and faster (uses memset)
|
||||
else
|
||||
resize(DEFAULT_SIZE, FALSE);
|
||||
resize(DEFAULT_SIZE, false);
|
||||
}
|
||||
|
||||
TString::TString() : _str(NULL), _size(0)
|
||||
{ resize(DEFAULT_SIZE, FALSE); }
|
||||
{ resize(DEFAULT_SIZE, false); }
|
||||
|
||||
TString::~TString()
|
||||
{
|
||||
@ -224,7 +223,6 @@ TString& TString::operator <<(const TString& str)
|
||||
// @mfunc Elimina tutti i caratteri contenuti in <p k>
|
||||
TString& TString::strip(
|
||||
const char* k) // @parm Stringa dei caratteri da eliminare
|
||||
|
||||
{
|
||||
int j = 0;
|
||||
for (const char* s = _str; *s; s++)
|
||||
@ -402,14 +400,13 @@ int TString::find(const char* s, int from) const
|
||||
return pos;
|
||||
}
|
||||
|
||||
bool TString::match(const char* pat) const
|
||||
bool TString::match(const char* pat, bool ignore_case) const
|
||||
{
|
||||
if (pat == NULL || *pat =='\0')
|
||||
return empty();
|
||||
return ::match(pat, _str);
|
||||
return xvt_str_match(_str, pat, !ignore_case) != 0;
|
||||
}
|
||||
|
||||
|
||||
int TString::replace(char find_char, char replace_char)
|
||||
{
|
||||
int n = 0;
|
||||
@ -432,13 +429,7 @@ const TString& TString::left(
|
||||
|
||||
// @rdesc Ritorna l'indirizzo della stringa contenente i <p count> caratteri da sinistra
|
||||
{
|
||||
if (count <= 0)
|
||||
return EMPTY_STRING;
|
||||
|
||||
TString& spark = get_tmp_string();
|
||||
spark = _str;
|
||||
spark.cut(count);
|
||||
return spark;
|
||||
return mid(0, count);
|
||||
}
|
||||
|
||||
// Certified 99%
|
||||
@ -450,14 +441,12 @@ const TString& TString::right(
|
||||
|
||||
// @rdesc Ritorna l'indirizzo della stringa contenente i <p count> caratteri da destra
|
||||
{
|
||||
TString& spark = get_tmp_string();
|
||||
int from = len()-count;
|
||||
if (from < 0) from = 0;
|
||||
spark = _str + from;
|
||||
return spark;
|
||||
if (from <= 0)
|
||||
from = 0;
|
||||
return mid(from);
|
||||
}
|
||||
|
||||
|
||||
// Certified 100%
|
||||
// @doc EXTERNAL
|
||||
|
||||
@ -469,19 +458,16 @@ const TString& TString::mid(
|
||||
|
||||
// @rdesc Ritorna l'indirizzo della stringa contenente i <p count> cartteri da <p from>
|
||||
{
|
||||
TString& spark = get_tmp_string();
|
||||
const int l = len();
|
||||
CHECKD(from >= 0, "Invalid MID parameter: from ", from);
|
||||
|
||||
#ifdef DBG
|
||||
if (from < 0)
|
||||
{
|
||||
NFCHECK("Invalid MID parameter: from = %d", from);
|
||||
from = 0;
|
||||
}
|
||||
#endif
|
||||
if (from > l) from = l;
|
||||
const int l = len();
|
||||
if (count < 0 || from+count>l)
|
||||
count = l-from;
|
||||
|
||||
if (from >= l || count == 0)
|
||||
return EMPTY_STRING;
|
||||
|
||||
TString& spark = get_tmp_string(count);
|
||||
spark.strncpy(&_str[from], count);
|
||||
return spark;
|
||||
}
|
||||
@ -555,7 +541,7 @@ TString& TString::rpad(const int n,const char c)
|
||||
const int l = len();
|
||||
if (n > l)
|
||||
{
|
||||
if (n > size()) resize(n, TRUE);
|
||||
if (n > size()) resize(n, true);
|
||||
memset(_str+l, c, n-l);
|
||||
_str[n] = '\0';
|
||||
}
|
||||
@ -570,7 +556,7 @@ TString& TString::lpad(const int n,const char c)
|
||||
const int nsp=n-l;
|
||||
if (n>l)
|
||||
{
|
||||
if (n > size()) resize(n, TRUE);
|
||||
if (n > size()) resize(n, true);
|
||||
for (l--; l>=0; l--)
|
||||
*(_str+l+nsp)=*(_str+l);
|
||||
memset(_str, c, nsp);
|
||||
@ -597,12 +583,16 @@ TString& TString::ltrim(
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
if (count >= len()) return cut(0);
|
||||
if (count >= len())
|
||||
return cut(0);
|
||||
s = &_str[count];
|
||||
}
|
||||
else for (s = _str; *s && is_space(*s); s++);
|
||||
else
|
||||
for (s = _str; *s && is_space(*s); s++);
|
||||
|
||||
if (s != _str) strcpy(_str, s);
|
||||
if (s != _str)
|
||||
strcpy(_str, s);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -671,7 +661,7 @@ TString& TString::trim()
|
||||
int TString::compare(
|
||||
const char* s, // @parm Stringa da comparare
|
||||
int max, // @parm Numero di caratteri da conforntare (default tutta la stringa)
|
||||
bool ignorecase) const // @parm Ignorare la differenza maiuscolo/minuscolo (default FALSE)
|
||||
bool ignorecase) const // @parm Ignorare la differenza maiuscolo/minuscolo (default false)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
@ -720,9 +710,9 @@ bool TString::ends_with(const char* s, bool ignorecase) const
|
||||
else
|
||||
{
|
||||
if (ignorecase)
|
||||
yes = toupper(_str[mylen-1]) == toupper(s[slen-1]);
|
||||
yes = toupper(_str[mylen-1]) == toupper(s[0]);
|
||||
else
|
||||
yes = _str[mylen-1] == s[slen-1];
|
||||
yes = _str[mylen-1] == s[0];
|
||||
}
|
||||
}
|
||||
return yes;
|
||||
@ -750,7 +740,7 @@ TString& TString::fill(
|
||||
n = size();
|
||||
else
|
||||
if (n > size())
|
||||
resize(n, FALSE);
|
||||
resize(n, false);
|
||||
memset(_str, c, n);
|
||||
_str[n] = '\0';
|
||||
return *this;
|
||||
@ -865,11 +855,11 @@ TString& TString::picture(
|
||||
// Certified 99% (s != NULL)
|
||||
int TString::strncpy(const char* s, int n)
|
||||
{
|
||||
if (n > size())
|
||||
resize(n, FALSE);
|
||||
int i = 0;
|
||||
if (s && *s)
|
||||
{
|
||||
if (n > size())
|
||||
resize(n, false);
|
||||
for (; *s && i < n; i++)
|
||||
_str[i] = *s++;
|
||||
}
|
||||
@ -907,7 +897,7 @@ TString& TString::format(
|
||||
char* TString::get_buffer(int min_size)
|
||||
{
|
||||
if (min_size > size())
|
||||
resize(min_size, TRUE);
|
||||
resize(min_size, true);
|
||||
return _str;
|
||||
}
|
||||
|
||||
@ -983,7 +973,7 @@ TString& TString::overwrite(
|
||||
const int l = len();
|
||||
if (pos < 0) pos = l;
|
||||
const int max = pos+lung;
|
||||
if (max > size()) resize(max, TRUE); // resize needed?
|
||||
if (max > size()) resize(max, true); // resize needed?
|
||||
|
||||
const bool over = max > l; // beyond end of string?
|
||||
for (int i = l; i < pos; i++) _str[i] = ' '; // space padding per inserimenti dopo la fine della stringa
|
||||
@ -1110,12 +1100,12 @@ void TFilename::ext(const char* e)
|
||||
if (start < 0)
|
||||
start = len()-1;
|
||||
|
||||
bool can_cut = TRUE;
|
||||
bool can_cut = true;
|
||||
int i;
|
||||
for (i = start; i > 0 && _str[i] != '.'; i--)
|
||||
if (is_slash(_str[i]) || _str[i] == ':')
|
||||
{
|
||||
can_cut = FALSE;
|
||||
can_cut = false;
|
||||
i = start;
|
||||
break;
|
||||
}
|
||||
@ -1180,8 +1170,8 @@ TFilename& TFilename::add(const char* n)
|
||||
//
|
||||
// @rdesc Ritorna i seguenti valori
|
||||
//
|
||||
// @flag TRUE | Se il nome del file e' sintatticamente corretto
|
||||
// @flag FALSE | Se il nome del file non e' sintatticamente corretto
|
||||
// @flag true | Se il nome del file e' sintatticamente corretto
|
||||
// @flag false | Se il nome del file non e' sintatticamente corretto
|
||||
bool TFilename::ok() const
|
||||
|
||||
// @comm Controlla tutti i casi per cui un nome di file puo' non essere valido.
|
||||
@ -1191,7 +1181,7 @@ bool TFilename::ok() const
|
||||
const int l = len();
|
||||
|
||||
int len = 0; // lunghezza ultima sottostringa
|
||||
bool ext = FALSE; // trovata estensione
|
||||
bool ext = false; // trovata estensione
|
||||
|
||||
for (int c = 0; c < l; c++)
|
||||
{
|
||||
@ -1199,31 +1189,31 @@ bool TFilename::ok() const
|
||||
{
|
||||
#if XVT_OS == XVT_OS_WIN32
|
||||
case ':':
|
||||
if (c != 1 || !isalpha(_str[0])) return FALSE; // Nome disco errato
|
||||
if (c != 1 || !isalpha(_str[0])) return false; // Nome disco errato
|
||||
len = 0;
|
||||
break;
|
||||
case '\\':
|
||||
#endif
|
||||
case '/':
|
||||
if (ext) return FALSE; // Slash dopo estensione
|
||||
if (len > _MAX_FNAME) return FALSE; // Nome troppo lungo
|
||||
if (!isalnum(_str[++c])) return FALSE;
|
||||
if (ext) return false; // Slash dopo estensione
|
||||
if (len > _MAX_FNAME) return false; // Nome troppo lungo
|
||||
if (!isalnum(_str[++c])) return false;
|
||||
len = 1;
|
||||
break;
|
||||
case '.':
|
||||
if (len == 0 || ext) return FALSE; // Nome nullo o Doppia estensione
|
||||
ext = TRUE;
|
||||
if (len == 0 || ext) return false; // Nome nullo o Doppia estensione
|
||||
ext = true;
|
||||
len = 0;
|
||||
c++;
|
||||
default:
|
||||
if (isalnum(_str[c])) len++;
|
||||
else return FALSE;
|
||||
else return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ext && len > _MAX_EXT)
|
||||
return FALSE;
|
||||
return false;
|
||||
|
||||
return len > 0 && len <= _MAX_FNAME;
|
||||
}
|
||||
@ -1232,7 +1222,7 @@ bool TFilename::ok() const
|
||||
const TFilename& TFilename::tempdir()
|
||||
{
|
||||
static TFilename _tempdir;
|
||||
const bool create = _tempdir.empty() || user().compare(_tempdir.right(user().len()), -1, TRUE);
|
||||
const bool create = _tempdir.empty() || user().compare(_tempdir.right(user().len()), -1, true);
|
||||
|
||||
if (create)
|
||||
{
|
||||
@ -1248,7 +1238,7 @@ const TFilename& TFilename::tempdir()
|
||||
if (!is_not_slash(_str[last]))
|
||||
_tempdir.cut(last);
|
||||
|
||||
bool ok = TRUE;
|
||||
bool ok = true;
|
||||
|
||||
_tempdir.lower();
|
||||
if (!_tempdir.exist())
|
||||
@ -1607,7 +1597,7 @@ long TToken_string::get_long(int n)
|
||||
|
||||
// const TToken_string new age!
|
||||
|
||||
// @rdesc Ritorna TRUE se e' stata trovata una stringa alla posizione <p n>
|
||||
// @rdesc Ritorna true se e' stata trovata una stringa alla posizione <p n>
|
||||
bool TToken_string::get(
|
||||
int n, // @parm Posizione del token da ritornare (0 = primo, -1 = prossimo, -2 = ultimo, n = n-simo)
|
||||
TString& tok) const // @parm Stringa da ritornare
|
||||
@ -1709,7 +1699,7 @@ bool TToken_string::set_item(const char* v, int n)
|
||||
for (;sep < n; sep++)
|
||||
*this << _separator;
|
||||
*this << v;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
int e = find(_separator, i);
|
||||
@ -1718,7 +1708,7 @@ bool TToken_string::set_item(const char* v, int n)
|
||||
spark = _str+e; // Salva items seguenti
|
||||
cut(i); // Considera solo items precedenti
|
||||
*this << v << spark; // Aggiunge item desiderato e seguenti
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -1746,8 +1736,8 @@ bool TToken_string::empty_items() const
|
||||
{
|
||||
for (const char* c = _str; *c; c++)
|
||||
if (!is_space(*c) && *c != _separator)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Certified 80%
|
||||
@ -2035,7 +2025,7 @@ int TString_array::find(
|
||||
{
|
||||
int found = -1;
|
||||
for (int i = from; i < items(); i++)
|
||||
if (row(i).compare(s, -1, TRUE) == 0)
|
||||
if (row(i).compare(s, -1, true) == 0)
|
||||
{
|
||||
found = i;
|
||||
break;
|
||||
|
@ -90,13 +90,13 @@ public:
|
||||
// @cmember Ritorna la lunghezza della stringa (numero di caratteri)
|
||||
int len() const
|
||||
{ return _str ? strlen(_str) : 0; }
|
||||
// @cmember Controlla se la stringa e' vuota (TRUE se non contiene caratteri)
|
||||
// @cmember Controlla se la stringa e' vuota (true se non contiene caratteri)
|
||||
bool empty() const
|
||||
{ return *_str == '\0'; }
|
||||
// @cmember Controlla se la stringa non e' vuota (TRUE se contiene caratteri)
|
||||
// @cmember Controlla se la stringa non e' vuota (true se contiene caratteri)
|
||||
bool not_empty() const
|
||||
{ return *_str != '\0'; }
|
||||
// @cmember Controlla se la stringa e' vuota o contiene solo whitespace (TRUE se vuota)
|
||||
// @cmember Controlla se la stringa e' vuota o contiene solo whitespace (true se vuota)
|
||||
bool blank() const;
|
||||
|
||||
// @cmember Ritorna la posizione della prima occorrenza carattere char nell'oggetto TString
|
||||
@ -241,13 +241,13 @@ public:
|
||||
{ return strcmp(_str, s._str) != 0; }
|
||||
// @cmember Controlla se una stringa e' minore di un'altra
|
||||
bool operator <(const char* s) const
|
||||
{ return s ? strcmp(_str, s) < 0 : FALSE;}
|
||||
{ return s ? strcmp(_str, s) < 0 : false;}
|
||||
// @cmember Controlla se una stringa e' maggiore di un'altra
|
||||
bool operator >(const char* s) const
|
||||
{ return s ? strcmp(_str, s) > 0 : not_empty();}
|
||||
// @cmember Controlla se una stringa e' maggiore o uguale ad un'altra
|
||||
bool operator >=(const char* s) const
|
||||
{ return s ? strcmp(_str, s) >= 0 : TRUE;}
|
||||
{ return s ? strcmp(_str, s) >= 0 : true;}
|
||||
// @cmember Controlla se una stringa e' minore o uguale ad un'altra
|
||||
bool operator <=(const char* s) const
|
||||
{ return s ? strcmp(_str, s) <= 0 : empty();}
|
||||
@ -264,13 +264,13 @@ public:
|
||||
bool operator <=(const TString & s) const
|
||||
{ return strcmp(_str, s._str) <= 0; }
|
||||
// @cmember Confronta usando le regular expression
|
||||
bool match(const char* pat) const;
|
||||
bool match(const char* pat, bool ignorecase = false) const;
|
||||
// @cmember Compara due stringhe (o i primi max caratteri)
|
||||
int compare(const char* s, int max = -1, bool ignorecase = FALSE) const;
|
||||
int compare(const char* s, int max = -1, bool ignorecase = false) const;
|
||||
// @cmember Controlla se la strinvga comincia per s
|
||||
bool starts_with(const char* s, bool ignorecase = FALSE) const;
|
||||
bool starts_with(const char* s, bool ignorecase = false) const;
|
||||
// @cmember Controlla se la strinvga finisce per s
|
||||
bool ends_with(const char* s, bool ignorecase = FALSE) const;
|
||||
bool ends_with(const char* s, bool ignorecase = false) const;
|
||||
};
|
||||
|
||||
// @doc EXTERNAL
|
||||
@ -719,7 +719,7 @@ public:
|
||||
// @cmember Cerca una stringa nell'array
|
||||
int find(const char* s, int from = 0) const;
|
||||
// @cmember Ordina alfabeticamente l'array
|
||||
void sort(bool ascendig = TRUE);
|
||||
void sort(bool ascendig = true);
|
||||
|
||||
// @cmember Costruttore
|
||||
TString_array(int size = 8) : TArray(size)
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#include <printer.h>
|
||||
#include <regexp.h>
|
||||
#include <relation.h>
|
||||
#include <text.h>
|
||||
#include <window.h>
|
||||
@ -465,13 +464,13 @@ long TTextfile::search(
|
||||
|
||||
// @comm Cerca in una riga per volta rispettando i formati
|
||||
{
|
||||
TString lin(512);
|
||||
TString text(txt);
|
||||
if (!casesens)
|
||||
text.lower();
|
||||
if (regexp && text.right(1) != "*")
|
||||
if (regexp && !text.ends_with("*"))
|
||||
text << '*';
|
||||
|
||||
TString lin(512);
|
||||
for (long i = from; down ? (i < lines()) : (i >= 0); down ? i++ : i--)
|
||||
{
|
||||
lin = line(i);
|
||||
@ -481,7 +480,7 @@ long TTextfile::search(
|
||||
{
|
||||
for (ret = 0; lin[ret]; ret++)
|
||||
{
|
||||
if (match(text, lin.mid(ret)))
|
||||
if (lin.mid(ret).match(text))
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user