diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-11-16 23:04:33 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2009-11-16 23:04:33 +0100 |
| commit | ab2f4dbc8daa65f95dbb2c75ad11f20435f8c140 (patch) | |
| tree | 5775e86cf6663d4978f05fc1339809e9fda850ec /libgtk_kylix/GTKUtils.pas | |
| parent | f1521a509a4ecec67480ac04c7732300a6baab13 (diff) | |
| download | tuxcmd-ab2f4dbc8daa65f95dbb2c75ad11f20435f8c140.tar.xz | |
Avoid double-formatting strings containing percent sign
Diffstat (limited to 'libgtk_kylix/GTKUtils.pas')
| -rw-r--r-- | libgtk_kylix/GTKUtils.pas | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libgtk_kylix/GTKUtils.pas b/libgtk_kylix/GTKUtils.pas index 787b133..3f92168 100644 --- a/libgtk_kylix/GTKUtils.pas +++ b/libgtk_kylix/GTKUtils.pas @@ -45,6 +45,7 @@ function GDKColorToPGdkColor(Color: TGDKColor): PGdkColor; function PGdkColorToGDKColor(Color: PGdkColor): TGDKColor; function GDKColorToString(Color: TGDKColor): string; function StringToGDKColor(Str: string; var Color: TGDKColor): boolean; +function EscapeFormatStr(const Str: string): string; (********************************************************************************************************************************) implementation @@ -207,5 +208,21 @@ begin end; (********************************************************************************************************************************) +function EscapeFormatStr(const Str: string): string; +var i: integer; + src: string; +begin + src := Str; + Result := ''; + repeat + i := Pos('%', src); + if i > 0 then begin + Result := Result + Copy(src, 1, i - 1) + '%%'; + src := Copy(src, i + 1, MaxInt); + end else Result := Result + src; + until i <= 0; +end; + +(********************************************************************************************************************************) end. |
