Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

IsInteger/IsNaturalNumber should ignore whitespace #803

Merged
merged 2 commits into from

2 participants

@jmarshallnz
Owner

No description provided.

@jmarshallnz jmarshallnz was assigned
@jmarshallnz
Owner

Ok, updated, including some doxy and a unit test to confirm it does what it says :p

A quick review would be nice (just assign milestone when done).

@theuni
Owner

Also, any reason (other than avoiding a copy) for not using .Trim() rather than reimplementing?

@jmarshallnz
Owner

IMO it's clearer as it is, plus the current version works on std::string in case the world ended and we dropped CStdString. Will add some more tests.

@jmarshallnz jmarshallnz merged commit 5f8ba69 into from
@tru tru referenced this pull request from a commit in plexinc/plex-home-theater-public
@tru tru Hide Audio Output Mode in the in video settings.
Fixes #803
e391d27
@HolgerW1 HolgerW1 referenced this pull request from a commit in HolgerW1/xbmc
@itofzo itofzo Merge branch 'change_postprocess_ignore_hidden_pass_nzb_delete' into …
…development

* change_postprocess_ignore_hidden_pass_nzb_delete: closes gh-803

Change PostProcessing checks and rules

+ Change replace rules and inner workings   closes gh-393
+ Include PR-620-jayme-github Process files by size but reversed (biggest first)  closes gh-620
+ Add postProcessor checks: status, quality/filesize, already processed  closes gh-629
+ Change search for airdate in database instead of thetvdb
+ Add tv download dir as default manual post-process directory  closes gh-722
+ Add is_proper to nameparser
+ Change use quality from snatch history instead of status quality
+ PEP8

Add ignore hidden, pass nzb, delete empty to processTV

Add ignore hidden subfolders (subfolder starts with .)
Removing ignored_filestrings from postProcessor
because subfolders with . are not being processed.

Add pass (inherit) nzbName to subfolder
When no videofiles are in the mainfolder and there is only one subfolder,
pass nzbName to subfolder

Add delete empty folder  closes gh-777
For now only delete empty folders on scripts and automatic.
Safety net, with manual it's easier to browse and select root folder

+ Change some logging and error messages  closes gh-702 closes gh-664 closes
9f309a4
@HolgerW1 HolgerW1 referenced this pull request from a commit in HolgerW1/xbmc
@itofzo itofzo Merge branch 'development'
Add require/ignore words per show. Pull #799
Some notable examples below of using ignore/require words,
also the global ignore words in the webui under search settings.
Ignore webrip or 'xvid' while still getting web-dl.
Require a specific's groups rip, like QRUS or ignore one like mSD.
Grab HD rips but require it to have DD5 audio.
Require VFR (variable frame rate) for the show Top Gear.
Require Uncut or XL versions of a show (since TVDB does not allow 'duplicate' shows).
Do note that the ignore word logic comes before required words. So be careful on what you ignore.
The words are not case sensitive, and if you use multiple words then a release will be rejected if ANY match.

Fix bug on massEdit removing values not displayed (air-by-date, language, release ignore/require words).

Remove superfluous logging message when editing show.

Do not set a show to air-by-date if it contains Documentary -- fixes Top Gear

Update scene_exception url to point new github domain. Pull #810

Change PostProcessing checks and rules. Pull #803
Ignore subfolders that start with . instead of a specific ignore list.
Pass (inherit) nzbName to subfolder
Add postProcessor checks: status, quality/filesize, already processed.
Change use quality from snatch history instead of status quality
Delete empty folder (scripts and automatic modes, not manual).
Change search for airdate in database instead of thetvdb.
Includes PR-620-jayme-github Process files by size but reversed (biggest first).
Stop postprocessing when failing to create destination folder.

Update autoProcessTV to work in python 2 and 3 (note that sickbeard itself only works in 2.5+ and not 3). Pull #802

API and NZBGet cleanup. Pull #804
Updated NZBGet to allow setting username (requires NZBGet v11+).
Updated NZBGet to have real priority for (requires NZBGet v9+) instead of just adding to the top of the queue.
Change NZBGet host field to an url so that people can specify the protocol (http/https).

SB-API: PEP8 fixes, use unicode not string when returning show name for show.refresh / show.pause / show.update.
APIBuilder: Limit show list to 100 shows to ensure performance
(since the show list is used multiple times for different linked list)

Lower default RSS search freq. from 60 min to 40 mins.

Upgrade Jquery UI from 1.10.3 to 1.10.4. Pull #793

Quick pass over our .js to cleanup whitespace, add missing semicolons, url redirect fixes. Pull #795

Handle malformed tvshow.nfo files when using the Add Existing Show page and resolved
the loading indicator to not finish.

Fix Exception on adding the initial rootdir.

Add routines to check or clean config input from the GUI.

Change usenet-crawler to https

Use with openwhen opening/writing files so it will automatically close the file,
even if there is an exception. Applied whitespace PEP8 fixes to the files touched,
also remove obsolete functions using open.

Fix AttributeError exception for metadata if stripping genre/actor name when None. Pull #801

Torrent provider HDbits now supports backlog and proper searches.

Metadata: Mede8er added.
f64b94f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 31, 2012
  1. IsInteger/IsNaturalNumber should ignore whitespace

    Jonathan Marshall authored
Commits on Apr 1, 2012
This page is out of date. Refresh to see the latest.
Showing with 66 additions and 9 deletions.
  1. +53 −9 xbmc/utils/StringUtils.cpp
  2. +13 −0 xbmc/utils/StringUtils.h
View
62 xbmc/utils/StringUtils.cpp
@@ -296,21 +296,65 @@ CStdString StringUtils::SecondsToTimeString(long lSeconds, TIME_FORMAT format)
bool StringUtils::IsNaturalNumber(const CStdString& str)
{
- if (0 == (int)str.size())
- return false;
- for (int i = 0; i < (int)str.size(); i++)
+ size_t i = 0, n = 0;
+ // allow whitespace,digits,whitespace
+ while (i < str.size() && isspace(str[i]))
+ i++;
+ while (i < str.size() && isdigit(str[i]))
{
- if ((str[i] < '0') || (str[i] > '9')) return false;
+ i++; n++;
}
- return true;
+ while (i < str.size() && isspace(str[i]))
+ i++;
+ return i == str.size() && n > 0;
}
bool StringUtils::IsInteger(const CStdString& str)
{
- if (str.size() > 0 && str[0] == '-')
- return IsNaturalNumber(str.Mid(1));
- else
- return IsNaturalNumber(str);
+ size_t i = 0, n = 0;
+ // allow whitespace,-,digits,whitespace
+ while (i < str.size() && isspace(str[i]))
+ i++;
+ if (i < str.size() && str[i] == '-')
+ i++;
+ while (i < str.size() && isdigit(str[i]))
+ {
+ i++; n++;
+ }
+ while (i < str.size() && isspace(str[i]))
+ i++;
+ return i == str.size() && n > 0;
+}
+
+bool StringUtils::Test()
+{
+ bool ret = true;
+
+ ret |= IsNaturalNumber("10");
+ ret |= IsNaturalNumber(" 10");
+ ret |= IsNaturalNumber("0");
+ ret |= !IsNaturalNumber(" 1 0");
+ ret |= !IsNaturalNumber("1.0");
+ ret |= !IsNaturalNumber("1.1");
+ ret |= !IsNaturalNumber("0x1");
+ ret |= !IsNaturalNumber("blah");
+ ret |= !IsNaturalNumber("120 h");
+ ret |= !IsNaturalNumber(" ");
+ ret |= !IsNaturalNumber("");
+
+ ret |= IsInteger("10");
+ ret |= IsInteger(" -10");
+ ret |= IsInteger("0");
+ ret |= !IsInteger(" 1 0");
+ ret |= !IsInteger("1.0");
+ ret |= !IsInteger("1.1");
+ ret |= !IsInteger("0x1");
+ ret |= !IsInteger("blah");
+ ret |= !IsInteger("120 h");
+ ret |= !IsInteger(" ");
+ ret |= !IsInteger("");
+
+ return ret;
}
void StringUtils::RemoveCRLF(CStdString& strLine)
View
13 xbmc/utils/StringUtils.h
@@ -59,7 +59,18 @@ class StringUtils
*/
static CStdString SecondsToTimeString(long seconds, TIME_FORMAT format = TIME_FORMAT_GUESS);
+ /*! \brief check whether a string is a natural number.
+ Matches [ \t]*[0-9]+[ \t]*
+ \param str the string to check
+ \return true if the string is a natural number, false otherwise.
+ */
static bool IsNaturalNumber(const CStdString& str);
+
+ /*! \brief check whether a string is an integer.
+ Matches [ \t]*[\-]*[0-9]+[ \t]*
+ \param str the string to check
+ \return true if the string is an integer, false otherwise.
+ */
static bool IsInteger(const CStdString& str);
static CStdString SizeToString(int64_t size);
static const CStdString EmptyString;
@@ -71,6 +82,8 @@ class StringUtils
static bool ValidateUUID(const CStdString &uuid); // NB only validates syntax
static double CompareFuzzy(const CStdString &left, const CStdString &right);
static int FindBestMatch(const CStdString &str, const CStdStringArray &strings, double &matchscore);
+
+ static bool Test();
private:
static CStdString m_lastUUID;
};
Something went wrong with that request. Please try again.