我可以重新编译Delphi IDE使用的.PAS文件吗? [英] Can I recompile the .PAS files used by the Delphi IDE?

查看:211
本文介绍了我可以重新编译Delphi IDE使用的.PAS文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉 Jeff Atwood关于错误总是程序员错误的文章。 a>,但我相信我真的真的发现了一个Delphi .pas文件中的错误。



具体来说,我使用的是Delphi 2007,错误是DBCommon.pas文件的第955行,我的机器位于这里:


C:\program files\codegear\ rad studio\5.0\source\Win32\db\DBCommon.pas


代码是这样的: p>

  ... 
FieldIndex:= StrToInt(Token);
如果DataSet.FieldCount> = FieldIndex然后
LastField:= DataSet.Fields [FieldIndex-1] .FieldName else
...
/ pre>

如果Token的值为零,那么我们尝试访问DataSet.Fields的索引-1,导致列表索引超出边界错误。



这个错误不是向用户提出的,因为它在获得高电平之前被处理,但是每次发生这种情况都会让调试器中断



我可以忽略这种异常类型,但是索引超出范围的错误是很常见的,我不想普遍忽略它们。



导致FieldIndex为零的情况是当您有一个SELECT语句,其ORDER BY包含一个函数,如:

  ORDER BY 
CASE WHEN FIELD1 = FIELD3 THEN 1 ELSE 2 END
,CASE WHEN FIELD2 = FIELD4 THEN 1 ELSE 2 END

我可以修复DBCommon.pas中的错误,但Delphi wi不会自己重新编译,我的更改不生效。如果我重命名.DCU文件,那么它只是抱怨说DBCommon.dcu找不到。



所以(最后)我的问题是:我可以重新编译DBCommon。 pas与我的修复,如果是,如何?

解决方案

你可以把dbcommon.pas放在youre项目目录中。随后将与项目的其余部分一起编制。


I am familiar with Jeff Atwood's article about how errors are always the programmer's fault, but I believe I have really and truly found a bug in a Delphi .pas file.

Specifically, I'm using Delphi 2007, and the error is on line 955 of the DBCommon.pas file, which on my machine is located here:

C:\program files\codegear\rad studio\5.0\source\Win32\db\DBCommon.pas

And the code is this:

...
  FieldIndex := StrToInt(Token);
  if DataSet.FieldCount >= FieldIndex then
    LastField := DataSet.Fields[FieldIndex-1].FieldName else
...

If "Token" has a value of zero, then we try to access index -1 of DataSet.Fields, resulting in a list index out of bounds error.

This error is not raised to the user, because it is handled before it gets that high up, but it is enormously irritating to have the debugger break in every time this happens.

I could "Ignore this exception type" but Index out of bounds errors are common enough that I don't want to universally ignore them.

The situation that causes FieldIndex to be zero is when you have a SELECT statement whose ORDER BY contains a function, as in:

ORDER BY
  CASE WHEN FIELD1 = FIELD3 THEN 1 ELSE 2 END
 ,CASE WHEN FIELD2 = FIELD4 THEN 1 ELSE 2 END

I can fix the bug in DBCommon.pas, but Delphi will not recompile itself, and my change does not take effect. If I rename the .DCU file, then it just complains that "DBCommon.dcu" cannot be found.

So (finally) my question is: Can I recompile DBCommon.pas with my fix, and if so, how?

解决方案

You can probably put dbcommon.pas in youre project directory. It will then be compiled along with the rest of the project.

这篇关于我可以重新编译Delphi IDE使用的.PAS文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆