summaryrefslogtreecommitdiff
path: root/UCoreUtils.pas
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2008-06-16 22:33:31 +0200
committerTomas Bzatek <tbzatek@redhat.com>2008-06-16 22:33:31 +0200
commit1c828670f3a5cffc32bf527ecac846161711ee45 (patch)
treeb0c890ad0c0ad8bce3052ae9e6bf674697e6af8e /UCoreUtils.pas
parent5fa771023dc8757f0b23861ef4dac2b4dd9efaf8 (diff)
downloadtuxcmd-1c828670f3a5cffc32bf527ecac846161711ee45.tar.xz
PPC (32bit) fixes
Diffstat (limited to 'UCoreUtils.pas')
-rw-r--r--UCoreUtils.pas27
1 files changed, 15 insertions, 12 deletions
diff --git a/UCoreUtils.pas b/UCoreUtils.pas
index 0bccb8b..93bbff0 100644
--- a/UCoreUtils.pas
+++ b/UCoreUtils.pas
@@ -195,13 +195,14 @@ begin
if f < 0 then f := ConfSizeFormat;
case f of
0 : begin // System default formatting
- p := malloc(255);
- memset(p, 0, 255);
- if sprintf(p, '%''lu', Value div Base) < 1 then begin
+ p := g_strdup_printf('%''lu', Int64(Value div Base));
+ if p = nil then begin
DebugMsg(['FormatSize(0): sprintf() failed, using old format function.']);
Result := FormatFloat('###,###,##0', Value div Base);
- end else Result := StrToUTF8(p);
- free(p);
+ end else begin
+ Result := StrToUTF8(p);
+ g_free(p);
+ end;
end;
1 : begin // 123456
Result := IntToStr(Value div Base);
@@ -308,7 +309,7 @@ begin
placed := strftime(Buf, 254, PChar(DateFormat), time_tm);
if placed <= 0 then DebugMsg(['FormatDate: error converting date. The result will be unpredictable.']);
DateString := String(StrToUTF8(Buf));
- free(Buf);
+ libc_free(Buf);
end;
if FormatTime then begin
@@ -332,7 +333,7 @@ begin
placed := strftime(Buf, 254, PChar(TimeFormat), time_tm);
if placed <= 0 then DebugMsg(['FormatDate: error converting time. The result will be unpredictable.']);
TimeString := String(StrToUTF8(Buf));
- free(Buf);
+ libc_free(Buf);
end;
if FormatDate and FormatTime then begin
@@ -1481,11 +1482,11 @@ end;
function StrToUTF8(s: PChar): PChar;
var bytes_read, bytes_written: gsize;
error: PGError;
- ns: PChar;
+ ns, nss: PChar;
m: PChar;
begin
if g_utf8_validate(s, strlen(s), nil) then begin
- Result := g_strndup(s, strlen(s));
+ Result := strndup(s, strlen(s));
Exit;
end;
// DebugMsg(['StrToUTF8: string "', s, '" is not valid UTF-8.']);
@@ -1502,9 +1503,11 @@ begin
g_error_free(error);
end;
if @g_filename_display_name <> nil then begin
- Result := g_filename_display_name(ns);
- g_free(ns);
- end else Result := ns;
+ nss := g_filename_display_name(ns);
+ Result := strdup(nss); // PPC compatibility
+ g_free(nss);
+ end else Result := strdup(ns); // PPC compatibility
+ g_free(ns);
end;
function UTF8ToStr(s: PChar): PChar;