all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Miles Bader <miles@gnu.org>
To: emacs-devel@gnu.org
Subject: Re: view/edit large files
Date: Wed, 18 Feb 2009 05:18:03 +0900	[thread overview]
Message-ID: <871vtw95s4.fsf@catnip.gol.com> (raw)
In-Reply-To: uzlgkvo9p.fsf@gnu.org

Eli Zaretskii <eliz@gnu.org> writes:
>> +  off_t beg_offset, end_offset;
>
> Is off_t guaranteed to be 64-bit wide?  If not, we lose the advantage
> of the floats, no?

If the system isn't capable of handling large files at all, then there's
no point in worrying about it, right?

>> +  beg_offset = FLOATP (beg) ? (off_t) XFLOAT_DATA (beg) : XINT (beg);
>> +  end_offset = FLOATP (end) ? (off_t) XFLOAT_DATA (end) : XINT (end);
>
> Shouldn't we round rather than truncate, when converting to off_t?

No.  The values being represented are integers.  The user almost
certainly will not be passing in a non-integral float; if he is doing
something weird so that he may end up with non-integral offsets, then
it's his job to worry about how such values are interpreted as integer
offsets.

Maybe it should guard against overflow in the conversion though (and
signal an error?).

>> -      if (XINT (beg) != 0)
>> +      if (beg_offset != 0)
>
> Exact equalities might be dangerous with floats.
>
>> -      if (same_at_start - BEGV_BYTE == XINT (end))
>> +      if (same_at_start - BEGV_BYTE == end_offset - beg_offset)
> Likewise.
>> -  if (XINT (beg) != 0 || !NILP (replace))
>> +  if (beg_offset != 0 || !NILP (replace))
> Likewise.

Comparing against zero here is fine -- a float can represent it exactly,
and there's no non-integer calculation to lose accuracy.

If there was overflow in the conversion to off_t, it probabably should
have been caught during the conversion.

-Miles

-- 
Discriminate, v.i. To note the particulars in which one person or thing is,
if possible, more objectionable than another.





  reply	other threads:[~2009-02-17 20:18 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-02 17:20 map-file-lines Ted Zlatanov
2009-02-02 18:54 ` map-file-lines Stefan Monnier
2009-02-02 19:22   ` map-file-lines Ted Zlatanov
2009-02-02 19:52     ` map-file-lines joakim
2009-02-02 20:54       ` map-file-lines Ted Zlatanov
2009-02-02 22:42         ` map-file-lines Stefan Monnier
2009-02-03 13:57           ` map-file-lines Ted Zlatanov
2009-02-02 22:41       ` map-file-lines Stefan Monnier
2009-02-02 23:59         ` map-file-lines joakim
2009-02-03  4:13           ` map-file-lines Stefan Monnier
2009-02-03  7:27             ` map-file-lines joakim
2009-02-03 14:50               ` map-file-lines Stefan Monnier
2009-02-04  7:04                 ` map-file-lines Richard M Stallman
2009-02-04 15:38                   ` map-file-lines Ted Zlatanov
2009-02-05  5:40                     ` map-file-lines Richard M Stallman
2009-02-06 18:42                       ` view/edit large files (was: map-file-lines) Ted Zlatanov
2009-02-06 21:06                         ` view/edit large files Ted Zlatanov
2009-02-06 21:49                           ` Miles Bader
     [not found]                             ` <864oz3nyj8.fsf@lifelogs.com>
2009-02-10  1:58                               ` Stefan Monnier
2009-02-10  8:46                                 ` Eli Zaretskii
2009-02-10  9:23                                   ` Miles Bader
2009-02-10  9:54                                     ` Eli Zaretskii
2009-02-10 10:02                                       ` Miles Bader
2009-02-10 11:50                                         ` Eli Zaretskii
2009-02-10 15:08                                           ` Ted Zlatanov
2009-02-17 19:23                                             ` Stefan Monnier
2009-02-17 19:47                                               ` Eli Zaretskii
2009-02-17 20:18                                                 ` Miles Bader [this message]
2009-02-17 20:51                                                   ` Eli Zaretskii
2009-02-17 21:19                                                     ` Miles Bader
2009-02-17 21:21                                                       ` Miles Bader
2009-02-18  4:09                                                         ` Eli Zaretskii
2009-02-18  1:56                                                 ` Stefan Monnier
2009-02-20 19:23                                                   ` Ted Zlatanov
2009-02-10 12:28                                     ` Eli Zaretskii
2009-02-10 12:46                                       ` Miles Bader
2009-02-07  9:14                         ` view/edit large files (was: map-file-lines) Richard M Stallman
2009-02-09 20:26                           ` view/edit large files Ted Zlatanov
2009-02-10 20:02                             ` Richard M Stallman
2009-02-06 13:20                 ` map-file-lines Mathias Dahl
2009-02-02 22:40     ` map-file-lines Stefan Monnier
2009-02-03  4:11       ` map-file-lines Stefan Monnier
2009-02-02 20:48 ` map-file-lines Ted Zlatanov
2009-02-03  8:08   ` map-file-lines Thien-Thi Nguyen
2009-02-03 14:00     ` map-file-lines Ted Zlatanov
2009-02-03 14:17       ` map-file-lines Miles Bader
2009-02-03 10:45   ` map-file-lines Thierry Volpiatto
2009-02-03 14:06     ` map-file-lines Ted Zlatanov
2009-02-03 14:56       ` map-file-lines Thierry Volpiatto
  -- strict thread matches above, loose matches on Subject: below --
2009-02-07  3:44 view/edit large files (was: map-file-lines) MON KEY
2009-02-08  4:34 ` Bob Rogers
2009-02-09 19:44   ` view/edit large files Thien-Thi Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871vtw95s4.fsf@catnip.gol.com \
    --to=miles@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.