diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2010-05-04 21:03:19 +0200 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2010-05-04 21:03:19 +0200 |
commit | 8a4168bd0d2e468604755398f18be1fba9046aa0 (patch) | |
tree | 56558e0517e3b63483a2813146563eaf0371c666 /strfct.c | |
parent | 75ebec3efc4879fc8bee8a3ecfe71809d9fccefd (diff) | |
download | vdr-plugin-graphlcd-8a4168bd0d2e468604755398f18be1fba9046aa0.tar.gz vdr-plugin-graphlcd-8a4168bd0d2e468604755398f18be1fba9046aa0.tar.bz2 |
initial git upload, based on graphlcd-0.2.0-pre2
Diffstat (limited to 'strfct.c')
-rw-r--r-- | strfct.c | 84 |
1 files changed, 42 insertions, 42 deletions
@@ -34,58 +34,58 @@ char * strncopy(char * dest , const char * src , size_t n) { - strncpy(dest, src, n); - if (strlen(src) >= n) - { - *(dest + n - 1) = 0; - } - return dest; + strncpy(dest, src, n); + if (strlen(src) >= n) + { + *(dest + n - 1) = 0; + } + return dest; } std::string trim(const std::string & s) { - std::string::size_type start, end; + std::string::size_type start, end; - start = 0; - while (start < s.length()) - { - if (!isspace(s[start])) - break; - start++; - } - end = s.length() - 1; - while (end >= 0) - { - if (!isspace(s[end])) - break; - end--; - } - return s.substr(start, end - start + 1); + start = 0; + while (start < s.length()) + { + if (!isspace(s[start])) + break; + start++; + } + end = s.length() - 1; + while (end >= 0) + { + if (!isspace(s[end])) + break; + end--; + } + return s.substr(start, end - start + 1); } std::string compactspace(const std::string & s) { - std::string str = ""; - std::string tmp; - unsigned int pos = 0; - unsigned int cnt = 0; - tmp = trim(s); - while (pos < tmp.length()) + std::string str = ""; + std::string tmp; + unsigned int pos = 0; + unsigned int cnt = 0; + tmp = trim(s); + while (pos < tmp.length()) + { + if (!isspace(tmp[pos])) + { + str += tmp[pos]; + cnt = 0; + } + else if (cnt == 0) { - if (!isspace(tmp[pos])) - { - str += tmp[pos]; - cnt = 0; - } - else if (cnt == 0) - { - str += tmp[pos]; - cnt++; - } - else - cnt++; - pos++; + str += tmp[pos]; + cnt++; } - return str; + else + cnt++; + pos++; + } + return str; } |