Репозитории ALT
S: | 2.1.41-alt23 |
5.1: | 2.1.41-alt9 |
4.1: | 2.1.41-alt3.M41.1 |
4.0: | 2.1.35-alt5 |
3.0: | 2.1.25-alt3 |
+backports: | 2.1.29-alt4.0.M30 |
Группа :: Система/Основа
Пакет: menu
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: menu-2.1.41-alt-substr-function.patch
Скачать
Скачать
--- menu-2.1.14/install-menu/install-menu.cc~ 2004-06-18 19:22:01 +0400
+++ menu-2.1.14/install-menu/install-menu.cc 2004-06-18 19:22:11 +0400
@@ -185,6 +185,7 @@ void add_functions()
store_func(new functions::translate);
store_func(new functions::encode_translate);
store_func(new functions::encode);
+ store_func(new functions::substr);
}
cat_str *get_eq_cat_str(parsestream &i)
--- menu-2.1.14/install-menu/functions.h~ 2004-06-18 19:23:19 +0400
+++ menu-2.1.14/install-menu/functions.h 2004-06-18 19:23:01 +0400
@@ -307,6 +307,12 @@ namespace functions {
const char * getName() const {return "encode";}
};
+ struct substr:public funcN<3>{
+ std::ostream &output(std::ostream &o, std::vector<cat_str *> &,
+ std::map<std::string, std::string> &);
+ const char * getName() const {return "substr";}
+ };
+
}
#endif
--- menu-2.1.41/install-menu/functions.cc~ 2008-11-10 17:48:15 +0300
+++ menu-2.1.41/install-menu/functions.cc 2008-11-10 17:48:51 +0300
@@ -29,6 +29,8 @@
#include <stringtoolbox.h>
#include <iostream>
#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <unistd.h>
using std::ostream;
@@ -570,4 +571,32 @@ ostream &encode::output(ostream &o, vect
return o << buf;
}
+/*
+ * this method get substring from string
+ */
+ostream &substr::output(ostream &o, vector<cat_str *> &args,
+ map<string, string> &menuentry){
+ int ps, sz;
+ string s=args[0]->soutput(menuentry);
+ string sps=args[1]->soutput(menuentry);
+ string ssz=args[2]->soutput(menuentry);
+
+ if ( !s.length() )
+ return o << s;
+
+ ps = atoi( sps.c_str() );
+ if ( ps < 0 )
+ ps = 0;
+ if ( ps >= s.length() )
+ ps = s.length() - 1;
+
+ sz = atoi( ssz.c_str() );
+ if ( sz < 0 )
+ sz = 0;
+ if ( ps + sz > s.length() )
+ sz = s.length() - ps;
+
+ return o << s.substr( ps, sz );
+}
+
}