summary refs log tree commit diff stats
path: root/nim/strutils.pas
diff options
context:
space:
mode:
Diffstat (limited to 'nim/strutils.pas')
-rw-r--r--nim/strutils.pas23
1 files changed, 22 insertions, 1 deletions
diff --git a/nim/strutils.pas b/nim/strutils.pas
index b654b7868..d70fdd8c3 100644
--- a/nim/strutils.pas
+++ b/nim/strutils.pas
@@ -56,6 +56,7 @@ function toUpper(c: Char): Char; overload;
 function toUpper(s: string): string; overload;
 
 function parseInt(const s: string): int;
+function parseBiggestInt(const s: string): BiggestInt;
 function ParseFloat(const s: string; checkEnd: Boolean = True): Real;
 
 function repeatChar(count: int; c: Char = ' '): string;
@@ -74,8 +75,18 @@ const
 function strip(const s: string; const chars: TCharSet = WhiteSpace): string;
 function allCharsInSet(const s: string; const theSet: TCharSet): bool;
 
+function quoteIfSpaceExists(const s: string): string;
+
 implementation
 
+function quoteIfSpaceExists(const s: string): string;
+begin
+  if (findSubStr(' ', s) >= strStart) and (s[strStart] <> '"') then
+    result := '"' +{&} s +{&} '"'
+  else
+    result := s
+end;
+
 function allCharsInSet(const s: string; const theSet: TCharSet): bool;
 var
   i: int;
@@ -511,7 +522,7 @@ begin
           while (j <= length(f)) and (f[j] in PatternChars) do inc(j);
           x := find(ncopy(f, i+1, j-1), args);
           if (x >= 0) and (x < high(args)) then result := result + args[x+1]
-          else raise EInvalidFormatStr.create('');
+          else raise EInvalidFormatStr.create(ncopy(f, i+1, j-1));
           i := j
         end
         else raise EInvalidFormatStr.create('');
@@ -584,6 +595,16 @@ begin
     result := int(res) // convert to smaller int type
 end;
 
+function parseBiggestInt(const s: string): BiggestInt;
+var
+  index: int;
+  res: BiggestInt;
+begin
+  index := strStart;
+  result := rawParseInt(s, index);
+  if index = -1 then raise EInvalidValue.create('')
+end;
+
 {@ignore}
 {$ifopt Q+} {$Q-}
 {$else}     {$define Q_on}