unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: static declaration inside `window_scroll_pixel_based' in window.c
@ 2006-03-09  0:49 Luc Teirlinck
  2006-03-09  2:04 ` Chong Yidong
  0 siblings, 1 reply; 6+ messages in thread
From: Luc Teirlinck @ 2006-03-09  0:49 UTC (permalink / raw)


>From my earlier message:

   Anyway, if the above quote from `(elisp)Writing Emacs Primitives' does
   apply here, the problem would be easy to fix with the following patch,
   which I can install if desired.

No, I responded too quickly.  The patch is incorrect, since it always
re-initializes preserve_y to -1 at the start of `window_scroll_pixel_based',
defeating its static-ness. 

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 6+ messages in thread
* static declaration inside `window_scroll_pixel_based' in window.c
@ 2006-03-09  0:27 Luc Teirlinck
  2006-03-11 15:46 ` Richard Stallman
  0 siblings, 1 reply; 6+ messages in thread
From: Luc Teirlinck @ 2006-03-09  0:27 UTC (permalink / raw)


`(elisp)Writing Emacs Primitives' contains:

     You must not use C initializers for static or global variables unless
  the variables are never written once Emacs is dumped.  These variables
  with initializers are allocated in an area of memory that becomes
  read-only (on certain operating systems) as a result of dumping Emacs.
  *Note Pure Storage::.

     Do not use static variables within functions--place all static
  variables at top level in the file.  This is necessary because Emacs on
  some operating systems defines the keyword `static' as a null macro.
  (This definition is used because those systems put all variables
  declared static in a place that becomes read-only after dumping, whether
  they have initializers or not.)

but preserve_y is declared a static int and initialized to -1 in the
function `window_scroll_pixel_based' on line 4727 of window.c.  I know
there are exceptions to the above quoted rules.  If you are sure that
your code is not going to be used on one of the affected OS's, there
is no problem.  _Maybe_ that applies here, but I am not sure.  Does it?
At first view I would say no, but I have no idea what the problematic
OS's are.

Anyway, if the above quote from `(elisp)Writing Emacs Primitives' does
apply here, the problem would be easy to fix with the following patch,
which I can install if desired.

===File ~/window.c-diff=====================================
*** window.c	28 Feb 2006 10:26:44 -0600	1.537
--- window.c	08 Mar 2006 17:40:13 -0600	
***************
*** 215,220 ****
--- 215,224 ----
  
  int window_deletion_count;
  
+ /* Used by the function window_scroll_pixel_based */
+ 
+ static int preserve_y;
+ 
  #if 0 /* This isn't used anywhere.  */
  /* Nonzero means we can split a frame even if it is "unsplittable".  */
  static int inhibit_frame_unsplittable;
***************
*** 4724,4730 ****
    int this_scroll_margin;
    /* True if we fiddled the window vscroll field without really scrolling.   */
    int vscrolled = 0;
!   static int preserve_y = -1;
  
    SET_TEXT_POS_FROM_MARKER (start, w->start);
  
--- 4728,4735 ----
    int this_scroll_margin;
    /* True if we fiddled the window vscroll field without really scrolling.   */
    int vscrolled = 0;
! 
!   preserve_y = -1;
  
    SET_TEXT_POS_FROM_MARKER (start, w->start);
  
============================================================

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-03-11 15:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-09  0:49 static declaration inside `window_scroll_pixel_based' in window.c Luc Teirlinck
2006-03-09  2:04 ` Chong Yidong
2006-03-09  2:11   ` Luc Teirlinck
2006-03-09  2:40     ` Chong Yidong
  -- strict thread matches above, loose matches on Subject: below --
2006-03-09  0:27 Luc Teirlinck
2006-03-11 15:46 ` 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).