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 | |
| parent | f1521a509a4ecec67480ac04c7732300a6baab13 (diff) | |
| download | tuxcmd-ab2f4dbc8daa65f95dbb2c75ad11f20435f8c140.tar.xz | |
Avoid double-formatting strings containing percent sign
| -rw-r--r-- | UCoreUtils.pas | 9 | ||||
| -rw-r--r-- | UGnome.pas | 2 | ||||
| -rw-r--r-- | libgtk_kylix/GTKForms.pas | 2 | ||||
| -rw-r--r-- | libgtk_kylix/GTKUtils.pas | 17 |
4 files changed, 19 insertions, 11 deletions
diff --git a/UCoreUtils.pas b/UCoreUtils.pas index 299773a..b18c2f2 100644 --- a/UCoreUtils.pas +++ b/UCoreUtils.pas @@ -113,7 +113,6 @@ function StrToUTF8(s: string): string; overload; function UTF8ToStr(s: string): string; overload; function StrToUTF8(s: PChar): PChar; overload; function UTF8ToStr(s: PChar): PChar; overload; -// function EnsureUTF8String(s: string): string; overload; function EnsureUTF8String(s: PChar): PChar; overload; @@ -1644,14 +1643,6 @@ begin end; end; -{ -function EnsureUTF8String(s: string): string; -begin - Result := s; - if @g_filename_display_name <> nil then Result := g_filename_display_name(PChar(s)); -end; -} - function EnsureUTF8String(s: PChar): PChar; begin Result := s; @@ -1207,7 +1207,7 @@ begin Exit; end; Dialog := gtk_message_dialog_new(ParentWindow, GTK_DIALOG_MODAL or GTK_DIALOG_DESTROY_WITH_PARENT, TMessageStyleID[Integer(Style)], - GTK_BUTTONS_NONE, StringToPgchar(Text)); + GTK_BUTTONS_NONE, StringToPgchar(EscapeFormatStr(Text))); CheckBox := PGtkCheckButton(gtk_check_button_new_with_mnemonic(StringToPgchar(DontShowAgainText))); gtk_widget_show(PGtkWidget(CheckBox)); gtk_box_pack_end(GTK_BOX(GTK_DIALOG(Dialog).vbox), PGtkWidget(CheckBox), False, False, 12); diff --git a/libgtk_kylix/GTKForms.pas b/libgtk_kylix/GTKForms.pas index d6c650b..f1f5440 100644 --- a/libgtk_kylix/GTKForms.pas +++ b/libgtk_kylix/GTKForms.pas @@ -737,7 +737,7 @@ begin Exit; end; Dialog := gtk_message_dialog_new(ParentWindow, GTK_DIALOG_MODAL or GTK_DIALOG_DESTROY_WITH_PARENT, TMessageStyleID[Integer(Style)], - GTK_BUTTONS_NONE, StringToPgchar(Text)); + GTK_BUTTONS_NONE, StringToPgchar(EscapeFormatStr(Text))); for i := 1 to NumMessageButtons do if TMessageButton(i - 1) in Buttons then gtk_dialog_add_button(PGtkDialog(Dialog), MessageButtonID[i], i); 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. |
