Using saved parent location: http://bzr.savannah.gnu.org/r/emacs/trunk/ Now on revision 103877. ------------------------------------------------------------ revno: 103877 committer: Chong Yidong branch nick: trunk timestamp: Sat 2011-04-09 16:28:01 -0400 message: Cleanups to the ImageMagick code and docstrings. * lisp/image-mode.el (image-toggle-display-image): Signal an error if not in Image mode. (image-transform-mode, image-transform-resize) (image-transform-set-rotation): Doc fix. (image-transform-set-resize): Deleted. (image-transform-set-scale, image-transform-fit-to-height) (image-transform-fit-to-width): Handle image-toggle-display-image and image-transform-resize directly. * src/image.c (Fimagemagick_types): Doc fix, and comment cleanup. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-09 17:40:29 +0000 +++ lisp/ChangeLog 2011-04-09 20:28:01 +0000 @@ -1,3 +1,14 @@ +2011-04-09 Chong Yidong + + * image-mode.el (image-toggle-display-image): Signal an error if + not in Image mode. + (image-transform-mode, image-transform-resize) + (image-transform-set-rotation): Doc fix. + (image-transform-set-resize): Deleted. + (image-transform-set-scale, image-transform-fit-to-height) + (image-transform-fit-to-width): Handle image-toggle-display-image + and image-transform-resize directly. + 2011-04-08 Sho Nakatani * doc-view.el (doc-view-fit-width-to-window) === modified file 'lisp/image-mode.el' --- lisp/image-mode.el 2011-02-19 19:40:59 +0000 +++ lisp/image-mode.el 2011-04-09 20:28:01 +0000 @@ -469,6 +469,8 @@ "Show the image of the image file. Turn the image data into a real image, but only if the whole file was inserted." + (unless (derived-mode-p 'image-mode major-mode) + (error "The buffer is not in Image mode")) (let* ((filename (buffer-file-name)) (data-p (not (and filename (file-readable-p filename) @@ -485,8 +487,7 @@ (type (image-type file-or-data nil data-p)) (image0 (create-animated-image file-or-data type data-p)) (image (append image0 - (image-transform-properties image0) - )) + (image-transform-properties image0))) (props `(display ,image intangible ,image @@ -557,80 +558,86 @@ (defvar image-transform-minor-mode-map (let ((map (make-sparse-keymap))) -; (define-key map [(control ?+)] 'image-scale-in) -; (define-key map [(control ?-)] 'image-scale-out) -; (define-key map [(control ?=)] 'image-scale-none) -;; (define-key map "c f h" 'image-scale-fit-height) -;; (define-key map "c ]" 'image-rotate-right) + ;; (define-key map [(control ?+)] 'image-scale-in) + ;; (define-key map [(control ?-)] 'image-scale-out) + ;; (define-key map [(control ?=)] 'image-scale-none) + ;; (define-key map "c f h" 'image-scale-fit-height) + ;; (define-key map "c ]" 'image-rotate-right) map) - "Minor mode keymap for transforming the view of images Image mode.") + "Minor mode keymap `image-transform-mode'.") (define-minor-mode image-transform-mode - "minor mode for scaleing and rotation" - nil "image-transform" - image-transform-minor-mode-map) + "Minor mode for scaling and rotating images. +This minor mode has no effect unless Emacs is compiled with +ImageMagick support." + nil "image-transform" image-transform-minor-mode-map) -(defvar image-transform-resize nil - "The image resize operation. See the command - `image-transform-set-scale' for more information." ) +(defvar image-transform-resize nil + "The image resize operation. +Its value should be one of the following: + - nil, meaning no resizing. + - `fit-height', meaning to fit the image to the window height. + - `fit-width', meaning to fit the image to the window width. + - A number, which is a scale factor (the default size is 100).") (defvar image-transform-rotation 0.0) - (defun image-transform-properties (display) - "Calculate the display properties for transformations; scaling -and rotation. " - (let* - ((size (image-size display t)) - (height - (cond - ((and (numberp image-transform-resize) (eq 100 image-transform-resize)) - nil) - ((numberp image-transform-resize) - (* image-transform-resize (cdr size))) - ((eq image-transform-resize 'fit-height) - (- (nth 3 (window-inside-pixel-edges)) (nth 1 (window-inside-pixel-edges)))) - (t nil))) - (width (if (eq image-transform-resize 'fit-width) - (- (nth 2 (window-inside-pixel-edges)) (nth 0 (window-inside-pixel-edges)))))) - + "Rescale and/or rotate the current image. +The scale factor and rotation angle are given by the variables +`image-transform-resize' and `image-transform-rotation'. This +takes effect only if Emacs is compiled with ImageMagick support." + (let* ((size (image-size display t)) + (height + (cond + ((numberp image-transform-resize) + (unless (= image-transform-resize 100) + (* image-transform-resize (cdr size)))) + ((eq image-transform-resize 'fit-height) + (- (nth 3 (window-inside-pixel-edges)) + (nth 1 (window-inside-pixel-edges)))))) + (width (if (eq image-transform-resize 'fit-width) + (- (nth 2 (window-inside-pixel-edges)) + (nth 0 (window-inside-pixel-edges)))))) + ;;TODO fit-to-* should consider the rotation angle `(,@(if height (list :height height)) ,@(if width (list :width width)) ,@(if (not (equal 0.0 image-transform-rotation)) - (list :rotation image-transform-rotation)) - ;;TODO fit-to-* should consider the rotation angle - ))) + (list :rotation image-transform-rotation))))) (defun image-transform-set-scale (scale) - "SCALE sets the scaling for images. " - (interactive "nscale:") - (image-transform-set-resize (float scale))) + "Prompt for a number, and resize the current image by that amount. +This command has no effect unless Emacs is compiled with +ImageMagick support." + (interactive "nScale: ") + (setq image-transform-resize resize) + (image-toggle-display-image)) (defun image-transform-fit-to-height () - "Fit image height to window height. " + "Fit the current image to the height of the current window. +This command has no effect unless Emacs is compiled with +ImageMagick support." (interactive) - (image-transform-set-resize 'fit-height)) + (setq image-transform-resize 'fit-height) + (image-toggle-display-image)) (defun image-transform-fit-to-width () - "Fit image width to window width. " + "Fit the current image to the width of the current window. +This command has no effect unless Emacs is compiled with +ImageMagick support." (interactive) - (image-transform-set-resize 'fit-width)) - -(defun image-transform-set-resize (resize) - "Set the resize mode for images. The RESIZE value can be the -symbol fit-height which fits the image to the window height. The -symbol fit-width fits the image to the window width. A number -indicates a scaling factor. nil indicates scale to 100%. " - (setq image-transform-resize resize) - (if (eq 'image-mode major-mode) (image-toggle-display-image))) + (setq image-transform-resize 'fit-width) + (image-toggle-display-image)) (defun image-transform-set-rotation (rotation) - "Set the image ROTATION angle. " - (interactive "nrotation:") + "Prompt for an angle ROTATION, and rotate the image by that amount. +ROTATION should be in degrees. This command has no effect unless +Emacs is compiled with ImageMagick support." + (interactive "nRotation angle (in degrees): ") ;;TODO 0 90 180 270 degrees are the only reasonable angles here ;;otherwise combining with rescaling will get very awkward (setq image-transform-rotation (float rotation)) - (if (eq major-mode 'image-mode) (image-toggle-display-image))) + (image-toggle-display-image)) (provide 'image-mode) === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-09 17:40:29 +0000 +++ src/ChangeLog 2011-04-09 20:28:01 +0000 @@ -1,5 +1,9 @@ 2011-04-09 Chong Yidong + * image.c (Fimagemagick_types): Doc fix, and comment cleanup. + +2011-04-09 Chong Yidong + * ftfont.c (get_adstyle_property, ftfont_pattern_entity): Use unsigned char, to match FcChar8 type definition. === modified file 'src/image.c' --- src/image.c 2011-04-05 20:06:52 +0000 +++ src/image.c 2011-04-09 20:28:01 +0000 @@ -7370,14 +7370,13 @@ /*********************************************************************** - imagemagick + ImageMagick ***********************************************************************/ #if defined (HAVE_IMAGEMAGICK) -/* The symbol `imagemagick' identifying images of this type. */ - Lisp_Object Qimagemagick; -/* Indices of image specification fields in imagemagick_format, below. */ + +/* Indices of image specification fields in imagemagick_format. */ enum imagemagick_keyword_index { @@ -7418,6 +7417,7 @@ {":rotation", IMAGE_NUMBER_VALUE, 0}, {":crop", IMAGE_DONT_CHECK_VALUE_TYPE, 0} }; + /* Free X resources of imagemagick image IMG which is used on frame F. */ static void @@ -7427,8 +7427,6 @@ x_clear_image (f, img); } - - /* Return non-zero if OBJECT is a valid IMAGEMAGICK image specification. Do this by calling parse_image_spec and supplying the keywords that identify the IMAGEMAGICK format. */ @@ -7457,7 +7455,7 @@ Uses librimagemagick to do most of the image processing. - non-zero when successful. + Return non-zero if successful. */ static int @@ -7504,12 +7502,12 @@ Image * im_image; - /* Handle image index for image types who can contain more than one - image. Interface :index is same as for GIF. First we "ping" the - image to see how many sub-images it contains. Pinging is faster - than loading the image to find out things about it. */ + /* Handle image index for image types who can contain more than one image. + Interface :index is same as for GIF. First we "ping" the image to see how + many sub-images it contains. Pinging is faster than loading the image to + find out things about it. */ - /* `MagickWandGenesis' initializes the imagemagick environment. */ + /* Initialize the imagemagick environment. */ MagickWandGenesis (); image = image_spec_value (img->spec, QCindex, NULL); ino = INTEGERP (image) ? XFASTINT (image) : 0; @@ -7541,7 +7539,7 @@ DestroyMagickWand (ping_wand); /* Now, after pinging, we know how many images are inside the - file. If its not a bundle, just one. */ + file. If it's not a bundle, the number is one. */ if (filename != NULL) { @@ -7572,7 +7570,7 @@ if (status == MagickFalse) goto imagemagick_error; /* If width and/or height is set in the display spec assume we want - to scale to those values. if either h or w is unspecified, the + to scale to those values. If either h or w is unspecified, the unspecified should be calculated from the specified to preserve aspect ratio. */ @@ -7584,17 +7582,13 @@ height = MagickGetImageHeight (image_wand); width = MagickGetImageWidth (image_wand); - if(desired_width != -1 && desired_height == -1) - { - /* w known, calculate h. */ - desired_height = (double) desired_width / width * height; - } - if(desired_width == -1 && desired_height != -1) - { - /* h known, calculate w. */ - desired_width = (double) desired_height / height * width; - } - if(desired_width != -1 && desired_height != -1) + if (desired_width != -1 && desired_height == -1) + /* w known, calculate h. */ + desired_height = (double) desired_width / width * height; + if (desired_width == -1 && desired_height != -1) + /* h known, calculate w. */ + desired_width = (double) desired_height / height * width; + if (desired_width != -1 && desired_height != -1) { status = MagickScaleImage (image_wand, desired_width, desired_height); if (status == MagickFalse) @@ -7604,19 +7598,17 @@ } } - /* crop behaves similar to image slicing in Emacs but is more memory efficient. */ crop = image_spec_value (img->spec, QCcrop, NULL); if (CONSP (crop) && INTEGERP (XCAR (crop))) { - /* After some testing, it seems MagickCropImage is the fastest - crop function in ImageMagick. This crop function seems to do - less copying than the alternatives, but it still reads the - entire image into memory before croping, which is aparently - difficult to avoid when using imagemagick. */ - + /* After some testing, it seems MagickCropImage is the fastest crop + function in ImageMagick. This crop function seems to do less copying + than the alternatives, but it still reads the entire image into memory + before croping, which is aparently difficult to avoid when using + imagemagick. */ int w, h, x, y; w = XFASTINT (XCAR (crop)); crop = XCDR (crop); @@ -7877,12 +7869,10 @@ }; - - DEFUN ("imagemagick-types", Fimagemagick_types, Simagemagick_types, 0, 0, 0, - doc: /* Return image file types supported by ImageMagick. -Since ImageMagick recognizes a lot of file-types that clash with Emacs, -such as .c, we want to be able to alter the list at the lisp level. */) + doc: /* Return the image types supported by ImageMagick. +Note that ImageMagick recognizes many file-types that Emacs does not recognize +as images, such as .c. */) (void) { Lisp_Object typelist = Qnil; ------------------------------------------------------------ revno: 103876 [merge] committer: Glenn Morris branch nick: trunk timestamp: Sat 2011-04-09 10:40:29 -0700 message: Merge from emacs-23; up to r100544. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-09 06:59:26 +0000 +++ lisp/ChangeLog 2011-04-09 17:40:29 +0000 @@ -684,7 +684,7 @@ (emerge-protect-metachars): Quote correctly for ms-dos and windows-nt systems. -2011-03-19 Ralph Schleicher +2011-03-19 Ralph Schleicher (tiny change) * info.el (info-initialize): Replace all uses of `:' with path-separator for compatibility with non-Unix systems. === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-09 16:35:19 +0000 +++ src/ChangeLog 2011-04-09 17:40:29 +0000 @@ -1,3 +1,13 @@ +2011-04-09 Chong Yidong + + * ftfont.c (get_adstyle_property, ftfont_pattern_entity): Use + unsigned char, to match FcChar8 type definition. + + * xterm.c (handle_one_xevent): + * xmenu.c (create_and_show_popup_menu): + * xselect.c (x_decline_selection_request) + (x_reply_selection_request): Avoid type-punned deref of X events. + 2011-04-09 Eli Zaretskii Fix some uses of `int' instead of EMACS_INT. @@ -39,7 +49,7 @@ * ccl.c (Fccl_execute_on_string): Declare some variables EMACS_INT. -2011-04-08 Svante Signell (tiny change) +2011-04-08 Samuel Thibault (tiny change) * term.c (init_tty): Fix incorrect ifdef placement (Bug#8450). === modified file 'src/ftfont.c' --- src/ftfont.c 2011-03-19 05:03:30 +0000 +++ src/ftfont.c 2011-04-09 17:40:29 +0000 @@ -160,7 +160,7 @@ static Lisp_Object get_adstyle_property (FcPattern *p) { - char *str, *end; + unsigned char *str, *end; Lisp_Object adstyle; if (FcPatternGetString (p, FC_STYLE, 0, (FcChar8 **) &str) != FcResultMatch) @@ -189,7 +189,7 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra) { Lisp_Object key, cache, entity; - char *file, *str; + unsigned char *file, *str; int idx; int numeric; double dbl; === modified file 'src/xmenu.c' --- src/xmenu.c 2011-04-05 20:26:55 +0000 +++ src/xmenu.c 2011-04-09 17:40:29 +0000 @@ -1529,7 +1529,8 @@ int i; Arg av[2]; int ac = 0; - XButtonPressedEvent dummy; + XEvent dummy; + XButtonPressedEvent *event = &(dummy.xbutton); LWLIB_ID menu_id; Widget menu; @@ -1547,36 +1548,35 @@ popup_deactivate_callback, menu_highlight_callback); - dummy.type = ButtonPress; - dummy.serial = 0; - dummy.send_event = 0; - dummy.display = FRAME_X_DISPLAY (f); - dummy.time = CurrentTime; - dummy.root = FRAME_X_DISPLAY_INFO (f)->root_window; - dummy.window = dummy.root; - dummy.subwindow = dummy.root; - dummy.x = x; - dummy.y = y; + event->type = ButtonPress; + event->serial = 0; + event->send_event = 0; + event->display = FRAME_X_DISPLAY (f); + event->time = CurrentTime; + event->root = FRAME_X_DISPLAY_INFO (f)->root_window; + event->window = event->subwindow = event->root; + event->x = x; + event->y = y; /* Adjust coordinates to be root-window-relative. */ x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f); y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f); - dummy.x_root = x; - dummy.y_root = y; + event->x_root = x; + event->y_root = y; - dummy.state = 0; - dummy.button = 0; + event->state = 0; + event->button = 0; for (i = 0; i < 5; i++) if (FRAME_X_DISPLAY_INFO (f)->grabbed & (1 << i)) - dummy.button = i; + event->button = i; /* Don't allow any geometry request from the user. */ XtSetArg (av[ac], XtNgeometry, 0); ac++; XtSetValues (menu, av, ac); /* Display the menu. */ - lw_popup_menu (menu, (XEvent *) &dummy); + lw_popup_menu (menu, &dummy); popup_activated_flag = 1; x_activate_timeout_atimer (); === modified file 'src/xselect.c' --- src/xselect.c 2011-04-02 02:02:18 +0000 +++ src/xselect.c 2011-04-09 17:40:29 +0000 @@ -499,22 +499,23 @@ static void x_decline_selection_request (struct input_event *event) { - XSelectionEvent reply; + XEvent reply_base; + XSelectionEvent *reply = &(reply_base.xselection); - reply.type = SelectionNotify; - reply.display = SELECTION_EVENT_DISPLAY (event); - reply.requestor = SELECTION_EVENT_REQUESTOR (event); - reply.selection = SELECTION_EVENT_SELECTION (event); - reply.time = SELECTION_EVENT_TIME (event); - reply.target = SELECTION_EVENT_TARGET (event); - reply.property = None; + reply->type = SelectionNotify; + reply->display = SELECTION_EVENT_DISPLAY (event); + reply->requestor = SELECTION_EVENT_REQUESTOR (event); + reply->selection = SELECTION_EVENT_SELECTION (event); + reply->time = SELECTION_EVENT_TIME (event); + reply->target = SELECTION_EVENT_TARGET (event); + reply->property = None; /* The reason for the error may be that the receiver has died in the meantime. Handle that case. */ BLOCK_INPUT; - x_catch_errors (reply.display); - XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply); - XFlush (reply.display); + x_catch_errors (reply->display); + XSendEvent (reply->display, reply->requestor, False, 0L, &reply_base); + XFlush (reply->display); x_uncatch_errors (); UNBLOCK_INPUT; } @@ -617,7 +618,8 @@ static void x_reply_selection_request (struct input_event *event, int format, unsigned char *data, int size, Atom type) { - XSelectionEvent reply; + XEvent reply_base; + XSelectionEvent *reply = &(reply_base.xselection); Display *display = SELECTION_EVENT_DISPLAY (event); Window window = SELECTION_EVENT_REQUESTOR (event); int bytes_remaining; @@ -629,15 +631,15 @@ if (max_bytes > MAX_SELECTION_QUANTUM) max_bytes = MAX_SELECTION_QUANTUM; - reply.type = SelectionNotify; - reply.display = display; - reply.requestor = window; - reply.selection = SELECTION_EVENT_SELECTION (event); - reply.time = SELECTION_EVENT_TIME (event); - reply.target = SELECTION_EVENT_TARGET (event); - reply.property = SELECTION_EVENT_PROPERTY (event); - if (reply.property == None) - reply.property = reply.target; + reply->type = SelectionNotify; + reply->display = display; + reply->requestor = window; + reply->selection = SELECTION_EVENT_SELECTION (event); + reply->time = SELECTION_EVENT_TIME (event); + reply->target = SELECTION_EVENT_TARGET (event); + reply->property = SELECTION_EVENT_PROPERTY (event); + if (reply->property == None) + reply->property = reply->target; BLOCK_INPUT; /* The protected block contains wait_for_property_change, which can @@ -648,8 +650,8 @@ #ifdef TRACE_SELECTION { - char *sel = XGetAtomName (display, reply.selection); - char *tgt = XGetAtomName (display, reply.target); + char *sel = XGetAtomName (display, reply->selection); + char *tgt = XGetAtomName (display, reply->target); TRACE3 ("%s, target %s (%d)", sel, tgt, ++x_reply_selection_request_cnt); if (sel) XFree (sel); if (tgt) XFree (tgt); @@ -664,10 +666,10 @@ { /* Send all the data at once, with minimal handshaking. */ TRACE1 ("Sending all %d bytes", bytes_remaining); - XChangeProperty (display, window, reply.property, type, format, + XChangeProperty (display, window, reply->property, type, format, PropModeReplace, data, size); /* At this point, the selection was successfully stored; ack it. */ - XSendEvent (display, window, False, 0L, (XEvent *) &reply); + XSendEvent (display, window, False, 0L, &reply_base); } else { @@ -693,19 +695,19 @@ error ("Attempt to transfer an INCR to ourself!"); TRACE2 ("Start sending %d bytes incrementally (%s)", - bytes_remaining, XGetAtomName (display, reply.property)); - wait_object = expect_property_change (display, window, reply.property, + bytes_remaining, XGetAtomName (display, reply->property)); + wait_object = expect_property_change (display, window, reply->property, PropertyDelete); TRACE1 ("Set %s to number of bytes to send", - XGetAtomName (display, reply.property)); + XGetAtomName (display, reply->property)); { /* XChangeProperty expects an array of long even if long is more than 32 bits. */ long value[1]; value[0] = bytes_remaining; - XChangeProperty (display, window, reply.property, dpyinfo->Xatom_INCR, + XChangeProperty (display, window, reply->property, dpyinfo->Xatom_INCR, 32, PropModeReplace, (unsigned char *) value, 1); } @@ -714,7 +716,7 @@ /* Tell 'em the INCR data is there... */ TRACE0 ("Send SelectionNotify event"); - XSendEvent (display, window, False, 0L, (XEvent *) &reply); + XSendEvent (display, window, False, 0L, &reply_base); XFlush (display); had_errors = x_had_errors_p (display); @@ -725,7 +727,7 @@ if (! had_errors) { TRACE1 ("Waiting for ACK (deletion of %s)", - XGetAtomName (display, reply.property)); + XGetAtomName (display, reply->property)); wait_for_property_change (wait_object); } else @@ -741,15 +743,15 @@ BLOCK_INPUT; wait_object - = expect_property_change (display, window, reply.property, + = expect_property_change (display, window, reply->property, PropertyDelete); TRACE1 ("Sending increment of %d elements", i); TRACE1 ("Set %s to increment data", - XGetAtomName (display, reply.property)); + XGetAtomName (display, reply->property)); /* Append the next chunk of data to the property. */ - XChangeProperty (display, window, reply.property, type, format, + XChangeProperty (display, window, reply->property, type, format, PropModeAppend, data, i); bytes_remaining -= i * format_bytes; if (format == 32) @@ -766,7 +768,7 @@ /* Now wait for the requester to ack this chunk by deleting the property. This can run random lisp code or signal. */ TRACE1 ("Waiting for increment ACK (deletion of %s)", - XGetAtomName (display, reply.property)); + XGetAtomName (display, reply->property)); wait_for_property_change (wait_object); } @@ -777,8 +779,8 @@ XSelectInput (display, window, 0L); TRACE1 ("Set %s to a 0-length chunk to indicate EOF", - XGetAtomName (display, reply.property)); - XChangeProperty (display, window, reply.property, type, format, + XGetAtomName (display, reply->property)); + XChangeProperty (display, window, reply->property, type, format, PropModeReplace, data, 0); TRACE0 ("Done sending incrementally"); } === modified file 'src/xterm.c' --- src/xterm.c 2011-04-01 20:14:03 +0000 +++ src/xterm.c 2011-04-09 17:40:29 +0000 @@ -4045,7 +4045,7 @@ return XSCROLL_BAR (bar); } - return 0; + return NULL; } @@ -6008,7 +6008,7 @@ goto OTHER; #endif /* USE_X_TOOLKIT */ { - XSelectionClearEvent *eventp = (XSelectionClearEvent *) &event; + XSelectionClearEvent *eventp = &(event.xselectionclear); inev.ie.kind = SELECTION_CLEAR_EVENT; SELECTION_EVENT_DISPLAY (&inev.sie) = eventp->display; @@ -6025,8 +6025,7 @@ goto OTHER; #endif /* USE_X_TOOLKIT */ { - XSelectionRequestEvent *eventp - = (XSelectionRequestEvent *) &event; + XSelectionRequestEvent *eventp = &(event.xselectionrequest); inev.ie.kind = SELECTION_REQUEST_EVENT; SELECTION_EVENT_DISPLAY (&inev.sie) = eventp->display; ------------------------------------------------------------ revno: 103875 committer: Eli Zaretskii branch nick: trunk timestamp: Sat 2011-04-09 19:35:19 +0300 message: Replace some uses of `int' with EMACS_INT. src/search.c (string_match_1, fast_string_match) (fast_c_string_match_ignore_case, fast_string_match_ignore_case) (scan_buffer, find_next_newline_no_quit) (find_before_next_newline, search_command, Freplace_match) (Fmatch_data): Make some `int' variables be EMACS_INT. src/xdisp.c (display_count_lines): 3rd argument and return value now EMACS_INT. All callers changed. (pint2hrstr): Last argument is now EMACS_INT. src/coding.c (detect_coding_utf_8, detect_coding_emacs_mule) (detect_coding_iso_2022, detect_coding_sjis, detect_coding_big5) (detect_coding_ccl, detect_coding_charset, decode_coding_utf_8) (decode_coding_utf_16, decode_coding_emacs_mule) (decode_coding_iso_2022, decode_coding_sjis, decode_coding_big5) (decode_coding_ccl, decode_coding_charset) : Declare EMACS_INT. (decode_coding_iso_2022, decode_coding_emacs_mule) (decode_coding_sjis, decode_coding_big5, decode_coding_charset) : Declare EMACS_INT. (encode_coding_utf_8, encode_coding_utf_16) (encode_coding_emacs_mule, encode_invocation_designation) (encode_designation_at_bol, encode_coding_iso_2022) (encode_coding_sjis, encode_coding_big5, encode_coding_ccl) (encode_coding_raw_text, encode_coding_charset) : Declare EMACS_INT. (ASSURE_DESTINATION): Declare more_bytes EMACS_INT. (encode_invocation_designation): Last argument P_NCHARS is now EMACS_INT. (decode_eol): Declare pos_byte, pos, and pos_end EMACS_INT. (produce_chars): from_nchars and to_nchars are now EMACS_INT. src/coding.h (struct coding_system) : Declare EMACS_INT. All users changed. src/ccl.c (Fccl_execute_on_string): Declare some variables EMACS_INT. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2011-04-08 18:53:26 +0000 +++ src/ChangeLog 2011-04-09 16:35:19 +0000 @@ -1,3 +1,44 @@ +2011-04-09 Eli Zaretskii + + Fix some uses of `int' instead of EMACS_INT. + * search.c (string_match_1, fast_string_match) + (fast_c_string_match_ignore_case, fast_string_match_ignore_case) + (scan_buffer, find_next_newline_no_quit) + (find_before_next_newline, search_command, Freplace_match) + (Fmatch_data): Make some `int' variables be EMACS_INT. + + * xdisp.c (display_count_lines): 3rd argument and return value now + EMACS_INT. All callers changed. + (pint2hrstr): Last argument is now EMACS_INT. + + * coding.c (detect_coding_utf_8, detect_coding_emacs_mule) + (detect_coding_iso_2022, detect_coding_sjis, detect_coding_big5) + (detect_coding_ccl, detect_coding_charset, decode_coding_utf_8) + (decode_coding_utf_16, decode_coding_emacs_mule) + (decode_coding_iso_2022, decode_coding_sjis, decode_coding_big5) + (decode_coding_ccl, decode_coding_charset) + : Declare EMACS_INT. + (decode_coding_iso_2022, decode_coding_emacs_mule) + (decode_coding_sjis, decode_coding_big5, decode_coding_charset) + : Declare EMACS_INT. + (encode_coding_utf_8, encode_coding_utf_16) + (encode_coding_emacs_mule, encode_invocation_designation) + (encode_designation_at_bol, encode_coding_iso_2022) + (encode_coding_sjis, encode_coding_big5, encode_coding_ccl) + (encode_coding_raw_text, encode_coding_charset) : + Declare EMACS_INT. + (ASSURE_DESTINATION): Declare more_bytes EMACS_INT. + (encode_invocation_designation): Last argument P_NCHARS is now + EMACS_INT. + (decode_eol): Declare pos_byte, pos, and pos_end EMACS_INT. + (produce_chars): from_nchars and to_nchars are now EMACS_INT. + + * coding.h (struct coding_system) : Declare EMACS_INT. + All users changed. + + * ccl.c (Fccl_execute_on_string): Declare some variables + EMACS_INT. + 2011-04-08 Svante Signell (tiny change) * term.c (init_tty): Fix incorrect ifdef placement (Bug#8450). === modified file 'src/ccl.c' --- src/ccl.c 2011-03-08 07:48:20 +0000 +++ src/ccl.c 2011-04-09 16:35:19 +0000 @@ -2049,7 +2049,7 @@ Lisp_Object val; struct ccl_program ccl; int i; - int outbufsize; + EMACS_INT outbufsize; unsigned char *outbuf, *outp; EMACS_INT str_chars, str_bytes; #define CCL_EXECUTE_BUF_SIZE 1024 === modified file 'src/coding.c' --- src/coding.c 2011-04-05 06:41:53 +0000 +++ src/coding.c 2011-04-09 16:35:19 +0000 @@ -159,7 +159,7 @@ const unsigned char *src = coding->source; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int found = 0; ...; @@ -266,7 +266,7 @@ unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; unsigned char *adjusted_dst_end = dst_end - _MAX_BYTES_PRODUCED_IN_LOOP_; - int produced_chars = 0; + EMACS_INT produced_chars = 0; for (; charbuf < charbuf_end && dst < adjusted_dst_end; charbuf++) { @@ -943,7 +943,7 @@ do { \ if (dst + (bytes) >= dst_end) \ { \ - int more_bytes = charbuf_end - charbuf + (bytes); \ + EMACS_INT more_bytes = charbuf_end - charbuf + (bytes); \ \ dst = alloc_destination (coding, more_bytes, dst); \ dst_end = coding->destination + coding->dst_bytes; \ @@ -1208,7 +1208,7 @@ const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int bom_found = 0; int found = 0; @@ -1293,7 +1293,7 @@ const unsigned char *src_base; int *charbuf = coding->charbuf + coding->charbuf_used; int *charbuf_end = coding->charbuf + coding->charbuf_size; - int consumed_chars = 0, consumed_chars_base = 0; + EMACS_INT consumed_chars = 0, consumed_chars_base = 0; int multibytep = coding->src_multibyte; enum utf_bom_type bom = CODING_UTF_8_BOM (coding); int eol_dos = @@ -1444,7 +1444,7 @@ int *charbuf_end = charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; - int produced_chars = 0; + EMACS_INT produced_chars = 0; int c; if (CODING_UTF_8_BOM (coding) == utf_with_bom) @@ -1602,7 +1602,7 @@ int *charbuf = coding->charbuf + coding->charbuf_used; /* We may produces at most 3 chars in one loop. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - 2; - int consumed_chars = 0, consumed_chars_base = 0; + EMACS_INT consumed_chars = 0, consumed_chars_base = 0; int multibytep = coding->src_multibyte; enum utf_bom_type bom = CODING_UTF_16_BOM (coding); enum utf_16_endian_type endian = CODING_UTF_16_ENDIAN (coding); @@ -1729,7 +1729,7 @@ int safe_room = 8; enum utf_bom_type bom = CODING_UTF_16_BOM (coding); int big_endian = CODING_UTF_16_ENDIAN (coding) == utf_16_big_endian; - int produced_chars = 0; + EMACS_INT produced_chars = 0; int c; if (bom != utf_without_bom) @@ -1863,7 +1863,7 @@ const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int c; int found = 0; @@ -2331,10 +2331,10 @@ loop and one more charset annotation at the end. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); - int consumed_chars = 0, consumed_chars_base; + EMACS_INT consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; - int char_offset = coding->produced_char; - int last_offset = char_offset; + EMACS_INT char_offset = coding->produced_char; + EMACS_INT last_offset = char_offset; int last_id = charset_ascii; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); @@ -2585,7 +2585,7 @@ unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; int safe_room = 8; - int produced_chars = 0; + EMACS_INT produced_chars = 0; Lisp_Object attrs, charset_list; int c; int preferred_charset_id = -1; @@ -2943,7 +2943,7 @@ int single_shifting = 0; int id; int c, c1; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int i; int rejected = 0; int found = 0; @@ -3453,7 +3453,7 @@ loop and one more charset annotation at the end. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 3); - int consumed_chars = 0, consumed_chars_base; + EMACS_INT consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; /* Charsets invoked to graphic plane 0 and 1 respectively. */ int charset_id_0 = CODING_ISO_INVOKED_CHARSET (coding, 0); @@ -3463,8 +3463,8 @@ int c; struct composition_status *cmp_status = CODING_ISO_CMP_STATUS (coding); Lisp_Object attrs = CODING_ID_ATTRS (coding->id); - int char_offset = coding->produced_char; - int last_offset = char_offset; + EMACS_INT char_offset = coding->produced_char; + EMACS_INT last_offset = char_offset; int last_id = charset_ascii; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); @@ -4190,10 +4190,10 @@ static unsigned char * encode_invocation_designation (struct charset *charset, struct coding_system *coding, - unsigned char *dst, int *p_nchars) + unsigned char *dst, EMACS_INT *p_nchars) { int multibytep = coding->dst_multibyte; - int produced_chars = *p_nchars; + EMACS_INT produced_chars = *p_nchars; int reg; /* graphic register number */ int id = CHARSET_ID (charset); @@ -4285,7 +4285,7 @@ /* Table of charsets to be designated to each graphic register. */ int r[4]; int c, found = 0, reg; - int produced_chars = 0; + EMACS_INT produced_chars = 0; int multibytep = coding->dst_multibyte; Lisp_Object attrs; Lisp_Object charset_list; @@ -4340,7 +4340,7 @@ int bol_designation = (CODING_ISO_FLAGS (coding) & CODING_ISO_FLAG_DESIGNATE_AT_BOL && CODING_ISO_BOL (coding)); - int produced_chars = 0; + EMACS_INT produced_chars = 0; Lisp_Object attrs, eol_type, charset_list; int ascii_compatible; int c; @@ -4528,7 +4528,7 @@ const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int found = 0; int c; Lisp_Object attrs, charset_list; @@ -4585,7 +4585,7 @@ const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int found = 0; int c; @@ -4636,13 +4636,13 @@ the end. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); - int consumed_chars = 0, consumed_chars_base; + EMACS_INT consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; struct charset *charset_roman, *charset_kanji, *charset_kana; struct charset *charset_kanji2; Lisp_Object attrs, charset_list, val; - int char_offset = coding->produced_char; - int last_offset = char_offset; + EMACS_INT char_offset = coding->produced_char; + EMACS_INT last_offset = char_offset; int last_id = charset_ascii; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); @@ -4754,12 +4754,12 @@ the end. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); - int consumed_chars = 0, consumed_chars_base; + EMACS_INT consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; struct charset *charset_roman, *charset_big5; Lisp_Object attrs, charset_list, val; - int char_offset = coding->produced_char; - int last_offset = char_offset; + EMACS_INT char_offset = coding->produced_char; + EMACS_INT last_offset = char_offset; int last_id = charset_ascii; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); @@ -4856,7 +4856,7 @@ unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; int safe_room = 4; - int produced_chars = 0; + EMACS_INT produced_chars = 0; Lisp_Object attrs, charset_list, val; int ascii_compatible; struct charset *charset_kanji, *charset_kana; @@ -4947,7 +4947,7 @@ unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; int safe_room = 4; - int produced_chars = 0; + EMACS_INT produced_chars = 0; Lisp_Object attrs, charset_list, val; int ascii_compatible; struct charset *charset_big5; @@ -5022,10 +5022,10 @@ const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int found = 0; unsigned char *valids; - int head_ascii = coding->head_ascii; + EMACS_INT head_ascii = coding->head_ascii; Lisp_Object attrs; detect_info->checked |= CATEGORY_MASK_CCL; @@ -5062,7 +5062,7 @@ const unsigned char *src_end = coding->source + coding->src_bytes; int *charbuf = coding->charbuf + coding->charbuf_used; int *charbuf_end = coding->charbuf + coding->charbuf_size; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; int multibytep = coding->src_multibyte; struct ccl_program *ccl = &coding->spec.ccl->ccl; int source_charbuf[1024]; @@ -5134,7 +5134,8 @@ unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; int destination_charbuf[1024]; - int i, produced_chars = 0; + EMACS_INT produced_chars = 0; + int i; Lisp_Object attrs, charset_list; CODING_GET_INFO (coding, attrs, charset_list); @@ -5220,7 +5221,7 @@ int *charbuf_end = coding->charbuf + coding->charbuf_used; unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; - int produced_chars = 0; + EMACS_INT produced_chars = 0; int c; if (multibytep) @@ -5303,10 +5304,10 @@ const unsigned char *src = coding->source, *src_base; const unsigned char *src_end = coding->source + coding->src_bytes; int multibytep = coding->src_multibyte; - int consumed_chars = 0; + EMACS_INT consumed_chars = 0; Lisp_Object attrs, valids, name; int found = 0; - int head_ascii = coding->head_ascii; + EMACS_INT head_ascii = coding->head_ascii; int check_latin_extra = 0; detect_info->checked |= CATEGORY_MASK_CHARSET; @@ -5410,12 +5411,12 @@ the end. */ int *charbuf_end = coding->charbuf + coding->charbuf_size - (MAX_ANNOTATION_LENGTH * 2); - int consumed_chars = 0, consumed_chars_base; + EMACS_INT consumed_chars = 0, consumed_chars_base; int multibytep = coding->src_multibyte; Lisp_Object attrs = CODING_ID_ATTRS (coding->id); Lisp_Object valids; - int char_offset = coding->produced_char; - int last_offset = char_offset; + EMACS_INT char_offset = coding->produced_char; + EMACS_INT last_offset = char_offset; int last_id = charset_ascii; int eol_dos = !inhibit_eol_conversion && EQ (CODING_ID_EOL_TYPE (coding->id), Qdos); @@ -5536,7 +5537,7 @@ unsigned char *dst = coding->destination + coding->produced; unsigned char *dst_end = coding->destination + coding->dst_bytes; int safe_room = MAX_MULTIBYTE_LENGTH; - int produced_chars = 0; + EMACS_INT produced_chars = 0; Lisp_Object attrs, charset_list; int ascii_compatible; int c; @@ -6444,7 +6445,7 @@ } else if (EQ (eol_type, Qdos)) { - int n = 0; + EMACS_INT n = 0; if (NILP (coding->dst_object)) { @@ -6459,9 +6460,9 @@ } else { - int pos_byte = coding->dst_pos_byte; - int pos = coding->dst_pos; - int pos_end = pos + coding->produced_char - 1; + EMACS_INT pos_byte = coding->dst_pos_byte; + EMACS_INT pos = coding->dst_pos; + EMACS_INT pos_end = pos + coding->produced_char - 1; while (pos < pos_end) { @@ -6646,7 +6647,7 @@ if (c >= 0) { - int from_nchars = 1, to_nchars = 1; + EMACS_INT from_nchars = 1, to_nchars = 1; Lisp_Object trans = Qnil; LOOKUP_TRANSLATION_TABLE (translation_table, c, trans); === modified file 'src/coding.h' --- src/coding.h 2011-01-25 04:08:28 +0000 +++ src/coding.h 2011-04-09 16:35:19 +0000 @@ -449,7 +449,7 @@ -1 in setup_coding_system, and updated by detect_coding. So, when this is equal to the byte length of the text being converted, we can skip the actual conversion process. */ - int head_ascii; + EMACS_INT head_ascii; /* The following members are set by encoding/decoding routine. */ EMACS_INT produced, produced_char, consumed, consumed_char; === modified file 'src/editfns.c' --- src/editfns.c 2011-03-30 00:17:26 +0000 +++ src/editfns.c 2011-04-09 16:35:19 +0000 @@ -750,7 +750,7 @@ /* It is possible that NEW_POS is not within the same field as OLD_POS; try to move NEW_POS so that it is. */ { - int shortage; + EMACS_INT shortage; Lisp_Object field_bound; if (fwd) === modified file 'src/fileio.c' --- src/fileio.c 2011-04-03 00:32:10 +0000 +++ src/fileio.c 2011-04-09 16:35:19 +0000 @@ -271,7 +271,7 @@ if (CONSP (elt)) { Lisp_Object string = XCAR (elt); - int match_pos; + EMACS_INT match_pos; Lisp_Object handler = XCDR (elt); Lisp_Object operations = Qnil; === modified file 'src/lisp.h' --- src/lisp.h 2011-04-08 15:37:15 +0000 +++ src/lisp.h 2011-04-09 16:35:19 +0000 @@ -2775,6 +2775,8 @@ extern void write_string (const char *, int); extern void print_error_message (Lisp_Object, Lisp_Object, const char *, Lisp_Object); +extern Lisp_Object internal_with_output_to_temp_buffer + (const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object); #define FLOAT_TO_STRING_BUFSIZE 350 extern void float_to_string (char *, double); extern void syms_of_print (void); @@ -3044,13 +3046,13 @@ extern struct re_pattern_buffer *compile_pattern (Lisp_Object, struct re_registers *, Lisp_Object, int, int); -extern int fast_string_match (Lisp_Object, Lisp_Object); -extern int fast_c_string_match_ignore_case (Lisp_Object, const char *); -extern int fast_string_match_ignore_case (Lisp_Object, Lisp_Object); +extern EMACS_INT fast_string_match (Lisp_Object, Lisp_Object); +extern EMACS_INT fast_c_string_match_ignore_case (Lisp_Object, const char *); +extern EMACS_INT fast_string_match_ignore_case (Lisp_Object, Lisp_Object); extern EMACS_INT fast_looking_at (Lisp_Object, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, Lisp_Object); extern EMACS_INT scan_buffer (int, EMACS_INT, EMACS_INT, EMACS_INT, - int *, int); + EMACS_INT *, int); extern EMACS_INT scan_newline (EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, EMACS_INT, int); extern EMACS_INT find_next_newline (EMACS_INT, int); === modified file 'src/search.c' --- src/search.c 2011-04-03 04:21:50 +0000 +++ src/search.c 2011-04-09 16:35:19 +0000 @@ -368,7 +368,7 @@ static Lisp_Object string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int posix) { - int val; + EMACS_INT val; struct re_pattern_buffer *bufp; EMACS_INT pos, pos_byte; int i; @@ -468,10 +468,10 @@ and return the index of the match, or negative on failure. This does not clobber the match data. */ -int +EMACS_INT fast_string_match (Lisp_Object regexp, Lisp_Object string) { - int val; + EMACS_INT val; struct re_pattern_buffer *bufp; bufp = compile_pattern (regexp, 0, Qnil, @@ -491,10 +491,10 @@ This does not clobber the match data. We assume that STRING contains single-byte characters. */ -int +EMACS_INT fast_c_string_match_ignore_case (Lisp_Object regexp, const char *string) { - int val; + EMACS_INT val; struct re_pattern_buffer *bufp; size_t len = strlen (string); @@ -511,10 +511,10 @@ /* Like fast_string_match but ignore case. */ -int +EMACS_INT fast_string_match_ignore_case (Lisp_Object regexp, Lisp_Object string) { - int val; + EMACS_INT val; struct re_pattern_buffer *bufp; bufp = compile_pattern (regexp, 0, Vascii_canon_table, @@ -643,7 +643,7 @@ EMACS_INT scan_buffer (register int target, EMACS_INT start, EMACS_INT end, - EMACS_INT count, int *shortage, int allow_quit) + EMACS_INT count, EMACS_INT *shortage, int allow_quit) { struct region_cache *newline_cache; int direction; @@ -933,7 +933,7 @@ EMACS_INT find_next_newline_no_quit (EMACS_INT from, EMACS_INT cnt) { - return scan_buffer ('\n', from, 0, cnt, (int *) 0, 0); + return scan_buffer ('\n', from, 0, cnt, (EMACS_INT *) 0, 0); } /* Like find_next_newline, but returns position before the newline, @@ -943,7 +943,7 @@ EMACS_INT find_before_next_newline (EMACS_INT from, EMACS_INT to, EMACS_INT cnt) { - int shortage; + EMACS_INT shortage; EMACS_INT pos = scan_buffer ('\n', from, to, cnt, &shortage, 1); if (shortage == 0) @@ -958,9 +958,9 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count, int direction, int RE, int posix) { - register int np; + register EMACS_INT np; EMACS_INT lim, lim_byte; - int n = direction; + EMACS_INT n = direction; if (!NILP (count)) { @@ -2524,7 +2524,7 @@ /* We build up the substituted string in ACCUM. */ Lisp_Object accum; Lisp_Object middle; - int length = SBYTES (newtext); + EMACS_INT length = SBYTES (newtext); accum = Qnil; @@ -2880,7 +2880,7 @@ len = 0; for (i = 0; i < search_regs.num_regs; i++) { - int start = search_regs.start[i]; + EMACS_INT start = search_regs.start[i]; if (start >= 0) { if (EQ (last_thing_searched, Qt) === modified file 'src/xdisp.c' --- src/xdisp.c 2011-04-05 20:11:37 +0000 +++ src/xdisp.c 2011-04-09 16:35:19 +0000 @@ -763,7 +763,7 @@ static void handle_line_prefix (struct it *); static void pint2str (char *, int, EMACS_INT); -static void pint2hrstr (char *, int, int); +static void pint2hrstr (char *, int, EMACS_INT); static struct text_pos run_window_scroll_functions (Lisp_Object, struct text_pos); static void reconsider_clip_changes (struct window *, struct buffer *); @@ -825,7 +825,8 @@ static int store_mode_line_string (const char *, Lisp_Object, int, int, int, Lisp_Object); static const char *decode_mode_spec (struct window *, int, int, Lisp_Object *); static void display_menu_bar (struct window *); -static int display_count_lines (EMACS_INT, EMACS_INT, int, EMACS_INT *); +static EMACS_INT display_count_lines (EMACS_INT, EMACS_INT, EMACS_INT, + EMACS_INT *); static int display_string (const char *, Lisp_Object, Lisp_Object, EMACS_INT, EMACS_INT, struct it *, int, int, int, int); static void compute_line_metrics (struct it *); @@ -19107,11 +19108,11 @@ }; static void -pint2hrstr (char *buf, int width, int d) +pint2hrstr (char *buf, int width, EMACS_INT d) { /* We aim to represent the nonnegative integer D as QUOTIENT.TENTHS * 10 ^ (3 * EXPONENT). */ - int quotient = d; + EMACS_INT quotient = d; int remainder = 0; /* -1 means: do not use TENTHS. */ int tenths = -1; @@ -19437,7 +19438,7 @@ case 'l': { EMACS_INT startpos, startpos_byte, line, linepos, linepos_byte; - int topline, nlines, height; + EMACS_INT topline, nlines, height; EMACS_INT junk; /* %c and %l are ignored in `frame-title-format'. */ @@ -19502,7 +19503,8 @@ EMACS_INT limit = BUF_BEGV (b); EMACS_INT limit_byte = BUF_BEGV_BYTE (b); EMACS_INT position; - int distance = (height * 2 + 30) * line_number_display_limit_width; + EMACS_INT distance = + (height * 2 + 30) * line_number_display_limit_width; if (startpos - distance > limit) { @@ -19705,17 +19707,17 @@ Set *BYTE_POS_PTR to 1 if we found COUNT lines, 0 if we hit LIMIT. */ -static int +static EMACS_INT display_count_lines (EMACS_INT start_byte, - EMACS_INT limit_byte, int count, + EMACS_INT limit_byte, EMACS_INT count, EMACS_INT *byte_pos_ptr) { register unsigned char *cursor; unsigned char *base; - register int ceiling; + register EMACS_INT ceiling; register unsigned char *ceiling_addr; - int orig_count = count; + EMACS_INT orig_count = count; /* If we are not in selective display mode, check only for newlines. */ ------------------------------------------------------------ revno: 103874 committer: Eli Zaretskii branch nick: trunk timestamp: Sat 2011-04-09 09:59:26 +0300 message: Produce more accurate results from file-size-human-readable. lisp/files.el (file-size-human-readable): Produce one digit after decimal, like "ls -lh" does. lisp/ls-lisp.el (ls-lisp-format-file-size): Allow for 7 characters in the file size representation. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-08 20:09:19 +0000 +++ lisp/ChangeLog 2011-04-09 06:59:26 +0000 @@ -12,6 +12,12 @@ 2011-04-08 Eli Zaretskii + * files.el (file-size-human-readable): Produce one digit after + decimal, like "ls -lh" does. + + * ls-lisp.el (ls-lisp-format-file-size): Allow for 7 characters in + the file size representation. + * simple.el (list-processes): If async subprocesses are not available, error out with a clear error message. === modified file 'lisp/files.el' --- lisp/files.el 2011-04-08 15:31:33 +0000 +++ lisp/files.el 2011-04-09 06:59:26 +0000 @@ -1162,7 +1162,10 @@ (while (and (>= file-size power) (cdr post-fixes)) (setq file-size (/ file-size power) post-fixes (cdr post-fixes))) - (format "%.0f%s%s" file-size + (format (if (> (mod file-size 1.0) 0.05) + "%.1f%s%s" + "%.0f%s%s") + file-size (if (and (eq flavor 'iec) (string= (car post-fixes) "k")) "K" (car post-fixes)) === modified file 'lisp/ls-lisp.el' --- lisp/ls-lisp.el 2011-04-08 15:31:33 +0000 +++ lisp/ls-lisp.el 2011-04-09 06:59:26 +0000 @@ -724,7 +724,7 @@ ls-lisp-filesize-f-fmt ls-lisp-filesize-d-fmt) file-size) - (format " %4s" (file-size-human-readable file-size)))) + (format " %7s" (file-size-human-readable file-size)))) (provide 'ls-lisp) ------------------------------------------------------------ revno: 103873 committer: Tassilo Horn branch nick: trunk timestamp: Fri 2011-04-08 22:09:19 +0200 message: Fit contents to emacs window support for doc-view by Sho Nakatani. 2011-03-28 Sho Nakatani gmail.com> * doc-view.el (doc-view-fit-width-to-window) (doc-view-fit-height-to-window, doc-view-fit-page-to-window): New functions for fitting the shown image to the Emacs window size. (doc-view-mode-map): Add bindings for the new functions. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-04-08 18:53:26 +0000 +++ lisp/ChangeLog 2011-04-08 20:09:19 +0000 @@ -1,3 +1,10 @@ +2011-04-08 Sho Nakatani + + * doc-view.el (doc-view-fit-width-to-window) + (doc-view-fit-height-to-window, doc-view-fit-page-to-window): New + functions for fitting the shown image to the Emacs window size. + (doc-view-mode-map): Add bindings for the new functions. + 2011-03-24 Juanma Barranquero * vc-annotate.el (vc-annotate-show-log-revision-at-line): === modified file 'lisp/doc-view.el' --- lisp/doc-view.el 2011-02-17 21:19:13 +0000 +++ lisp/doc-view.el 2011-04-08 20:09:19 +0000 @@ -328,6 +328,10 @@ ;; Zoom in/out. (define-key map "+" 'doc-view-enlarge) (define-key map "-" 'doc-view-shrink) + ;; Fit the image to the window + (define-key map "W" 'doc-view-fit-width-to-window) + (define-key map "H" 'doc-view-fit-height-to-window) + (define-key map "P" 'doc-view-fit-page-to-window) ;; Killing the buffer (and the process) (define-key map (kbd "k") 'doc-view-kill-proc-and-buffer) (define-key map (kbd "K") 'doc-view-kill-proc) @@ -664,6 +668,78 @@ (interactive (list doc-view-shrink-factor)) (doc-view-enlarge (/ 1.0 factor))) +(defun doc-view-fit-width-to-window () + "Fit the image width to the window width." + (interactive) + (let ((win-width (- (nth 2 (window-inside-pixel-edges)) + (nth 0 (window-inside-pixel-edges)))) + (slice (doc-view-current-slice))) + (if (not slice) + (let ((img-width (car (image-display-size + (image-get-display-property) t)))) + (doc-view-enlarge (/ (float win-width) (float img-width)))) + + ;; If slice is set + (let* ((slice-width (nth 2 slice)) + (scale-factor (/ (float win-width) (float slice-width))) + (new-slice (mapcar (lambda (x) (ceiling (* scale-factor x))) slice))) + + (doc-view-enlarge scale-factor) + (setf (doc-view-current-slice) new-slice) + (doc-view-goto-page (doc-view-current-page)))))) + +(defun doc-view-fit-height-to-window () + "Fit the image height to the window height." + (interactive) + (let ((win-height (- (nth 3 (window-inside-pixel-edges)) + (nth 1 (window-inside-pixel-edges)))) + (slice (doc-view-current-slice))) + (if (not slice) + (let ((img-height (cdr (image-display-size + (image-get-display-property) t)))) + ;; When users call 'doc-view-fit-height-to-window', + ;; they might want to go to next page by typing SPC + ;; ONLY once. So I used '(- win-height 1)' instead of + ;; 'win-height' + (doc-view-enlarge (/ (float (- win-height 1)) (float img-height)))) + + ;; If slice is set + (let* ((slice-height (nth 3 slice)) + (scale-factor (/ (float (- win-height 1)) (float slice-height))) + (new-slice (mapcar (lambda (x) (ceiling (* scale-factor x))) slice))) + + (doc-view-enlarge scale-factor) + (setf (doc-view-current-slice) new-slice) + (doc-view-goto-page (doc-view-current-page)))))) + +(defun doc-view-fit-page-to-window () + "Fit the image to the window. +More specifically, this function enlarges image by: + +min {(window-width / image-width), (window-height / image-height)} times." + (interactive) + (let ((win-width (- (nth 2 (window-inside-pixel-edges)) + (nth 0 (window-inside-pixel-edges)))) + (win-height (- (nth 3 (window-inside-pixel-edges)) + (nth 1 (window-inside-pixel-edges)))) + (slice (doc-view-current-slice))) + (if (not slice) + (let ((img-width (car (image-display-size + (image-get-display-property) t))) + (img-height (cdr (image-display-size + (image-get-display-property) t)))) + (doc-view-enlarge (min (/ (float win-width) (float img-width)) + (/ (float (- win-height 1)) (float img-height))))) + ;; If slice is set + (let* ((slice-width (nth 2 slice)) + (slice-height (nth 3 slice)) + (scale-factor (min (/ (float win-width) (float slice-width)) + (/ (float (- win-height 1)) (float slice-height)))) + (new-slice (mapcar (lambda (x) (ceiling (* scale-factor x))) slice))) + (doc-view-enlarge scale-factor) + (setf (doc-view-current-slice) new-slice) + (doc-view-goto-page (doc-view-current-page)))))) + (defun doc-view-reconvert-doc () "Reconvert the current document. Should be invoked when the cached images aren't up-to-date." ------------------------------------------------------------ Use --include-merges or -n0 to see merged revisions.