emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: where to put eol kludge


From: Thien-Thi Nguyen
Subject: Re: where to put eol kludge
Date: Fri, 16 May 2003 08:14:20 -0400

   From: Kenichi Handa <address@hidden>
   Date: Fri, 16 May 2003 20:07:47 +0900 (JST)

   I'd like to avoid introducing "#ifdef VMS" newly in a
   function that doesn't have it currently.

fully agreed.  generally this might be re-conceptualized as "#if
CODING_STOPS_AT_LAST_EOL", where vms just happens to be one beneficiary
(maybe there will be others).  the word "stops" is not 100% accurate,
unfortunately.

   Isn't [sydep.c `sys_write'] working?

it used to work becuase there was no chunking involved between
Fwrite_region and sys_write; basically, the end of the buffer given to
sys_write was taken to be EOF (or the gap), and so sys_write could do
the eol adjustments directly.  (the code in Fwrite_region is only part
of the kludge!)  since coding introduces chunking, end of buffer given
to sys_write can no longer be assumed to be EOF (or gap).

it seems i mis-stated the direction of the proposed kludge motion;
rather than moving it higher to lower, we need to keep its pre-amble
where it is (in Fwrite_region), and move its body from lower to higher,
integrating it w/ the chunking that goes on as part of encode_coding.

   Encoding is not stateless, so, as I wrote before, it's not
   easy to rewind the internal encoding state to the point of
   last eol.

ok.

   Anyway, we don't have to throw away the tail bytes of the
   encoding after eol even if we do that in e_write.  We can
   simply keep those bytes as carryover, move them to the head
   of `buf', then, call encode_coding as this:
      encode_coding (coding, addr, buf + CARRY_OVER_BYTES, 
                     nbytes, WRITE_BUF_SIZE - CARRY_OVER_BYTES);

eventually this is what i realized as well -- i'm glad you confirmed my
inklings!  how about something like:

  struct coding_system
  { ...
  #ifdef CODING_CARRIES_AFTER_LAST_EOL
    /* Last EOL.  */
    char *last_eol;
    /* Number of bytes to carry over after the last EOL encountered.  */
    int carry_over_bytes;
  #endif
  };

then macros EMIT_ONE_BYTE and EMIT_TWO_BYTES would set last_eol,
and encode_coding would need:

  #ifdef CODING_CARRIES_AFTER_LAST_EOL
    coding->carry_over_bytes = coding->produced - coding->last_eol;
  #endif

(rough sketch.)

thi




reply via email to

[Prev in Thread] Current Thread [Next in Thread]