* translate-region occasionally misses chars?
@ 2002-05-03 2:51 Peck, Jeff
2002-05-04 3:36 ` Richard Stallman
0 siblings, 1 reply; 5+ messages in thread
From: Peck, Jeff @ 2002-05-03 2:51 UTC (permalink / raw)
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]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: translate-region occasionally misses chars?
2002-05-03 2:51 Peck, Jeff
@ 2002-05-04 3:36 ` Richard Stallman
0 siblings, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2002-05-04 3:36 UTC (permalink / raw)
Cc: bug-gnu-emacs
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]
Can you find a reproducible test case to report? It is hard to debug
without that.
If you try the same test case over and over, do you get varying
results?
It fails on both my Win2k machines, I don't a have a unix/linux to test.
Please dont call Windows "win", and please don't call the whole system "Linux".
In hacker terminology, calling something a "win" is a form of praise.
If you wish to praise Microsoft Windows, you're free to do so; but if you
don't, then you might want to think twice about using the term "win2k".
As for the Linux system, it is more GNU than Linux, so please call it
"GNU/Linux". If you call it "Linux", you're giving someone else the
credit for our work, and that makes it hard for us to recruit support
for further work. See http://www.gnu.org/gnu/linux-and-gnu.html.
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: translate-region occasionally misses chars?
@ 2002-05-04 3:58 Peck, Jeff
2002-05-05 5:34 ` Richard Stallman
0 siblings, 1 reply; 5+ messages in thread
From: Peck, Jeff @ 2002-05-04 3:58 UTC (permalink / raw)
Cc: bug-gnu-emacs
Richard, sorry to be oblique;
In my daily life, "win2k" is a curse word.
I was just trying to apologize in advance for not being able to
test the problem on a real or clean or useful software platform.
Sorry if I appeared to lump those together with the 'l' word.
Soon as i get a free CPU, i be running maybe GNU on Mach or whatever.
[in a former life i was "peck@sun.com", remember emacstool?
yeah, good-riddance to that too.]
As for the bug, the problem is intermittant, but fails reliably for me.
The defun i sent is a reproducible as I have for now.
One time i ran it, an it failed on 50 of 50 trials.
[so I have now modified the procedure to insert to a regular buffer,
instead of *Messages*, i lost the first 35 iterations...]
I take it from your response that it did not fail when you tried it?
If so, that is in itself is useful information.
Was anyone else able to try it?
Did anyone else log a missed translation?
(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*"))
(buf3 (get-buffer-create "errors"))
)
(set-buffer buf3) (erase-buffer)
(insert (format "flip-string is %s\n" (substring flip-string 32 127)))
(insert (format "flop-string is %s\n" (substring flop-string 32 127)))
;; copy buf1 to buf2
(set-buffer buf2)
(erase-buffer)
(insert-buffer buf1)
(while (plusp n)
(let* ((t1 (translate-region (point-min) (point-max) flip-string))
(t2 (translate-region (point-min) (point-max) flip-string)))
(setq n (- n 1))
(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))))
(set-buffer buf3)
(insert (format "%d. error at %d: [%s] [%s] #%d #%d\n"
(- i n) comp str1 str2 t1 t2))
(set-buffer buf2)
(sit-for 1)
(erase-buffer)
(insert-buffer buf1)
)))))))
-----Original Message-----
From: Richard Stallman [mailto:rms@gnu.org]
Sent: Friday, May 03, 2002 8:37 PM
To: jeff.peck@intel.com
Cc: bug-gnu-emacs@gnu.org
Subject: Re: translate-region occasionally misses chars?
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]
Can you find a reproducible test case to report? It is hard to debug
without that.
If you try the same test case over and over, do you get varying
results?
It fails on both my Win2k machines, I don't a have a unix/linux to test.
Please dont call Windows "win", and please don't call the whole system
"Linux".
In hacker terminology, calling something a "win" is a form of praise.
If you wish to praise Microsoft Windows, you're free to do so; but if you
don't, then you might want to think twice about using the term "win2k".
As for the Linux system, it is more GNU than Linux, so please call it
"GNU/Linux". If you call it "Linux", you're giving someone else the
credit for our work, and that makes it hard for us to recruit support
for further work. See http://www.gnu.org/gnu/linux-and-gnu.html.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: translate-region occasionally misses chars?
2002-05-04 3:58 Peck, Jeff
@ 2002-05-05 5:34 ` Richard Stallman
0 siblings, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2002-05-05 5:34 UTC (permalink / raw)
Cc: bug-gnu-emacs
I take it from your response that it did not fail when you tried it?
No, I didn't try it because I didn't know whether it would fail
reliably. Now I can try it (though I hope someone else will do it
first).
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: translate-region occasionally misses chars?
@ 2002-06-07 16:33 Peck, Jeff
0 siblings, 0 replies; 5+ messages in thread
From: Peck, Jeff @ 2002-06-07 16:33 UTC (permalink / raw)
Cc: bug-gnu-emacs
Any news on this?
Has anyone else tried it?
-----Original Message-----
From: Richard Stallman [mailto:rms@gnu.org]
Sent: Saturday, May 04, 2002 10:35 PM
To: jeff.peck@intel.com
Cc: bug-gnu-emacs@gnu.org
Subject: Re: translate-region occasionally misses chars?
I take it from your response that it did not fail when you tried it?
No, I didn't try it because I didn't know whether it would fail
reliably. Now I can try it (though I hope someone else will do it
first).
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-06-07 16:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-07 16:33 translate-region occasionally misses chars? Peck, Jeff
-- strict thread matches above, loose matches on Subject: below --
2002-05-04 3:58 Peck, Jeff
2002-05-05 5:34 ` Richard Stallman
2002-05-03 2:51 Peck, Jeff
2002-05-04 3:36 ` Richard Stallman
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).