unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Gregory Heytings <gregory@heytings.org>
To: 46933@debbugs.gnu.org
Subject: bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos
Date: Thu, 04 Mar 2021 21:21:24 +0000	[thread overview]
Message-ID: <9cff0f8894f167925251@heytings.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 5308 bytes --]


(Disclaimer: I have no knowledge whatsoever about the ISO-2022-JP 
encoding, and although this looks like a bug, I'm not sure this is 
actually a bug; I report this at the suggesion of Eli in bug#46859.)

I downloaded the file [1], and converted it to the ISO-2022-JP encoding 
with iconv -t iso-2022-jp one.txt > iso-2022-jp.txt.  The resulting file 
is attached to this bug report.  It ends with two CRLFs, at byte offsets 
2993 and 2995.  However, after emacs -Q iso-2022-jp.txt, with M-: 
(goto-char (filepos-to-bufferpos POS 'exact)) we get:

POS = 2991, 2992: last but one visible character (HIRAGANA LETTER RU)
POS = 2993, 2994: last visible character (IDEOGRAPHIC FULL STOP)
POS = 2995, 2996: first CRLF
POS = 2997: second CRLF
POS = 2998: point-max
POS = 2999: first CRLF
POS = 3000, 3001: second CRLF
POS >= 3002: point-max

I would have expected:

POS = 2989, 2990: last but one visible character (HIRAGANA LETTER RU)
POS = 2991, 2992: last visible character (IDEOGRAPHIC FULL STOP)
POS = 2993, 2994: first CRLF
POS = 2995, 2996: second CRLF
POS >= 2997: point-max

The opposite operation M-: (bufferpos-to-filepos (- (point) POS) 'exact) 
apparently also has bugs; its return values are not coherent with the 
above ones:

POS = 0: 3003
POS = 1: 3001
POS = 2: 2999
POS = 3 (IDEOGRAPHIC FULL STOP): 2997
POS = 4 (HIRAGANA LETTER RU): 2995

I would have expected:

POS = 0: 2997
POS = 1: 2995
POS = 2: 2993
POS = 3 (IDEOGRAPHIC FULL STOP): 2991
POS = 4 (HIRAGANA LETTER RU): 2989

[1] https://darza.com/ecbackend/vendor/symfony/mime/Tests/Fixtures/samples/charsets/iso-2022-jp/one.txt

In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo version 1.16.0)
  of 2020-11-08, modified by Debian built on x86-ubc-01
Windowing system distributor 'The X.Org Foundation', version 11.0.12010000
System Description: Debian GNU/Linux bullseye/sid

Configured using:
  'configure --build x86_64-linux-gnu --prefix=/usr
  --sharedstatedir=/var/lib --libexecdir=/usr/lib
  --localstatedir=/var/lib --infodir=/usr/share/info
  --mandir=/usr/share/man --enable-libsystemd --with-pop=yes
  --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp
  --with-sound=alsa --without-gconf --with-mailutils --build
  x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
  --libexecdir=/usr/lib --localstatedir=/var/lib
  --infodir=/usr/share/info --mandir=/usr/share/man --enable-libsystemd
  --with-pop=yes
  --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp
  --with-sound=alsa --without-gconf --with-mailutils --with-cairo
  --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
  'CFLAGS=-g -O2
  -fdebug-prefix-map=/build/emacs-6jKC2B/emacs-27.1+1=. -fstack-protector-strong
  -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
  -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF
ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD
JSON PDUMPER LCMS2 GMP

Important settings:
   value of $LANG: en_US.UTF-8
   locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
   tooltip-mode: t
   global-eldoc-mode: t
   eldoc-mode: t
   electric-indent-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   line-number-mode: t
   transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

[-- Attachment #2: Type: text/plain, Size: 2997 bytes --]

ISO-2022-JP^[$B$O!"%$%s%?!<%M%C%H>e^[(B(^[$BFC$KEE;R%a!<%k^[(B)^[$B$J$I$G;H$o$l$kF|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!"$b$7$/$OJ8;z2=$1$r5/$3$9860x$H$J$k!#$=$N$?$a!"^[(BWindows^[$BMQ$NEE;R%a!<%k%/%i%$%"%s%H$G$"$C$F$bFH<+3HD%$NJ8;z$r;HMQ$9$k$H7Y9p$r=P$7$?$j!"$"$($F;H$($J$$$h$&$K@)8B$7$F$$$k$b$N$bB8:_$9$k!#$5$i$K$O^[(BISO-2022-JP^[$B$NHO0OFb$G$"$C$F$b^[(BCP932^[$B$OHsI8=`J8;z!J^[(BFULLWIDTH TILDE^[$BEy!K$r;}$D$N$GJ8;z2=$1$N860x$K$J$jF@$k!#^[(B
^[$B$^$?!"Id9f2=J}<0L>$r^[(BISO-2022-JP^[$B$H$7$F$$$k$N$K!"J8;z=89g$H$7$F$O^[(BJIS X 0212 (^[$B$$$o$f$kJd=u4A;z^[(B) ^[$B$d^[(BJIS X 0201^[$B$NJR2>L>J8;z=89g^[(B (^[$B$$$o$f$kH>3Q%+%J^[(B) ^[$B$r$bId9f2=$7$F$$$kNc$,$"$k$,!"^[(BISO-2022-JP^[$B$G$O$3$l$i$NJ8;z$r5vMF$7$F$$$J$$!#$3$l$i$NId9f2=$OFH<+3HD%$N<BAu$G$"$j!"Cf$K$O^[(BISO/IEC 2022^[$B$N;EMM$K=`5r$9$i$7$F$$$J$$$b$N$b$"$k^[(B[2]^[$B!#=>$C$F<u?.B&$NEE;R%a!<%k%/%i%$%"%s%H$,$3$l$i$NFH<+3HD%$KBP1~$7$F$$$J$$>l9g!"$=$NJ8;z$"$k$$$O$=$NJ8;z$r4^$`9T!";~$K$O%F%-%9%HA4BN$,J8;z2=$1$9$k$3$H$,$"$k!#^[(B


             reply	other threads:[~2021-03-04 21:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04 21:21 Gregory Heytings [this message]
2021-03-21 15:27 ` bug#46933: Possible bugs in filepos-to-bufferpos / bufferpos-to-filepos Eli Zaretskii
2021-03-27  5:38   ` handa
2021-03-27  7:54     ` Eli Zaretskii
2021-03-27 13:23       ` handa
2021-03-27 13:54         ` Eli Zaretskii
2021-03-28 14:29           ` handa
2021-03-28 14:51             ` Eli Zaretskii
2021-04-01 15:14               ` handa
2021-04-01 15:25                 ` Eli Zaretskii
2021-04-01 15:32                 ` Eli Zaretskii
2021-04-03 16:12                   ` handa
2022-06-20  0:59                     ` Lars Ingebrigtsen
2022-06-20 11:52                       ` Eli Zaretskii
2022-06-21 10:40                         ` Lars Ingebrigtsen
2022-06-21 12:14                           ` Eli Zaretskii
2022-06-22  4:17                             ` Lars Ingebrigtsen
2022-06-22 13:11                               ` Eli Zaretskii
2021-03-27 14:24     ` Gregory Heytings

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=9cff0f8894f167925251@heytings.org \
    --to=gregory@heytings.org \
    --cc=46933@debbugs.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).