From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Peck, Jeff" Newsgroups: gmane.emacs.bugs Subject: translate-region occasionally misses chars? Date: Thu, 2 May 2002 22:51:11 -0400 Sender: bug-gnu-emacs-admin@gnu.org Message-ID: <59F55CE047A6D51196360002A534A4AC0296C6D0@pysmsx102.py.intel.com> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: main.gmane.org 1020394452 31729 127.0.0.1 (3 May 2002 02:54:12 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 3 May 2002 02:54:12 +0000 (UTC) Return-path: Original-Received: from fencepost.gnu.org ([199.232.76.164]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 173TD1-0008Fe-00 for ; Fri, 03 May 2002 04:54:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 173TCy-00075B-00; Thu, 02 May 2002 22:54:08 -0400 Original-Received: from hdfdns01.hd.intel.com ([192.52.58.10] helo=mail1.hd.intel.com) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 173TAE-0006xO-00 for ; Thu, 02 May 2002 22:51:19 -0400 Original-Received: from pysmsxvs01.py.intel.com (pysmsxvs01.py.intel.com [146.152.3.51]) by mail1.hd.intel.com (8.11.6/8.11.6/d: solo.mc,v 1.36 2002/05/02 20:19:58 root Exp $) with SMTP id g432pIX00674 for ; Fri, 3 May 2002 02:51:18 GMT Original-Received: from pysmsx030.py.intel.com ([146.152.3.52]) by pysmsxvs01.py.intel.com (NAVGW 2.5.1.16) with SMTP id M2002050222511217253 for ; Thu, 02 May 2002 22:51:12 -0400 Original-Received: by pysmsx030.py.intel.com with Internet Mail Service (5.5.2653.19) id ; Thu, 2 May 2002 22:51:12 -0400 Original-To: bug-gnu-emacs@gnu.org X-Mailer: Internet Mail Service (5.5.2653.19) Errors-To: bug-gnu-emacs-admin@gnu.org X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Bug reports for GNU Emacs, the Swiss army knife of text editors List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.bugs:1120 X-Report-Spam: http://spam.gmane.org/gmane.emacs.bugs:1120 Running ntemacs 20.7 on Win2K, and with 21.2 the problem continues. Using translate-region, occasionally and intermittantly a character will *not* be translated. Attached is a function that demonstrates the problem. Starting from some buffer (I used Help-apropos "file" for my test) The routine copies buf1 to another buffer (buf2), and then applies translate-region to that buffer. The particular translation swaps each printing char with another, Z<=>E, Y<=>F, etc. so applying it twice should return the original buffer. But occasionally, as demonstrated by the output below, a single character will fail to be translated. [can't tell if it fails on pass1 or pass2, but it doesn't matter] Of course, it may not be translate-region's fault, I have other experience, not so reproducible, where a char in a file just appears to read in wrong! [that is, the buffer shows --nomodification-- but it there is a character that does not agree with the file]. If anyone knows what is happening, my eternal thanks. In the meantime, my use of translate-region is wrapped in a loop that compares the before to the double application and keeps trying until they are the same... bletch. It fails on both my Win2k machines, I don't a have a unix/linux to test. If someone can confirm this on other OS, that would be a comfort. It is intermittant, to you may need to try it a couple times. Sometimes it fails immediately and frequently, other times it takes longer. I have not found a correlation with OS activity, paging, filesystem or whatever. ;;; this routine applies translate-region and logs the errors to *Messages* ;;; print flip-string and flop-string for a convenient translation table ;;; to see that the erroneous chars really are 'missed translations' and ;;; not some random bit loss. (flop-string has no other purpose) (defun test-flip (n &optional i) (message "flip %d chars, %d times" (- (point-max)(point-min)) n) (sit-for 1) (setq i n) (let ((flip-string ; reverse chars and nums: (do ((str "") (i 0 (1+ i))) ((> i 255) str) (let ((chr (char-to-string (if (or (<= i 32) (>= i 127)) i (- 159 i))))) (setq str (concat str chr))))) (flop-string (do ((str "") (i 0 (1+ i))) ((> i 255) str) (let ((chr (char-to-string (if (or (<= i 32) (>= i 127)) i i)))) (setq str (concat str chr))))) (buf1 (current-buffer)) (buf2 (get-buffer-create "*flip*"))) (message "flip-string is %s" (substring flip-string 32 127)) (message "flop-string is %s" (substring flop-string 32 127)) ;; copy buf1 to buf2 (set-buffer buf2) (erase-buffer) (insert-buffer buf1) (while (plusp n) (progn (setq n (- n 1)) (translate-region (point-min) (point-max) flip-string) (translate-region (point-min) (point-max) flip-string) (let ((comp (abs (compare-buffer-substrings buf1 4 (- (point-max) 4) buf2 4 (- (point-max) 4))))) (if (not (zerop comp)) (let ((str1 (save-excursion (set-buffer buf1) (buffer-substring comp (+ comp 7)))) (str2 (buffer-substring comp (+ comp 7)))) (message "%d. error at %d: [%s] [%s]" (- i n) comp str1 str2) (sit-for 1) (erase-buffer) (insert-buffer buf1) ))))))) Here is output from one run against *Apropos* flip 12089 chars, 50 times flip-string is ~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFE DCBA@?>=<;:9876543210/.-,+*)('&%$#"! flop-string is !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ [\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Mark set 43. error at 1168: [oint. c] [oin+. c] 44. error at 144: [tation.] [tat6on.] 45. error at 579: [-x appe] [-x >ppe] 46. error at 1623: [ one. c] [ on:. c] 47. error at 2072: [ subdir] [ su=dir] 48. error at 2301: [ FILE-B] [ FISE-B] 49. error at 216: [me RET ] [me MET ] 50. error at 372: [additio] [add6tio]