Fix problems found by static checking --with-ns

This is for Fedora 24 when configured with --enable-gcc-warnings.
Although it does not fix all the problems, it fixes many of them.
* src/frame.c (XParseGeometry):
* src/nsterm.m (mouseDown:):
Mark locals with UNINIT to pacify --enable-gcc-warnings.
* src/image.c (PIX_MASK_DRAW, DefaultDepthOfScreen):
Remove unused macros.
(slurp_file xbm_scan, xbm_read_bitmap_data, xbm_load_image)
(xbm_file_p, xbm_load, xpm_scan, xpm_make_color_table_v)
(xpm_put_color_table_v, xpm_get_color_table_v)
(xpm_make_color_table_h, xpm_put_color_table_h)
(xpm_get_color_table_h, xpm_load_image, xpm_load)
(pbm_next_char, pbm_scan_number, pbm_load, svg_load)
(svg_load_image):
* src/nsfns.m (x_get_string_resource):
* src/nsimage.m (ns_image_from_XBM):
Fix pointer signedness problems.
* src/image.c (xpm_load_image, x_build_heuristic_mask, pbm_load)
(imagemagick_load_image): Omit unused locals.
* src/nsfns.m (ns_send_types, ns_return_types, ns_drag_types)
(Fx_open_connection):
* src/nsfont.m (ns_antialias_threshold):
Move extern decl to nsterm.h so it can be checked.
* src/nsmenu.m (svcsMenu, dockMenu):
Move to the only file that uses them, so they can be static.
* src/nsterm.h (find_and_call_menu_selection):
* src/nsterm.m (x_set_frame_alpha):
Omit duplicate decls.
* src/nsterm.h (ns_dump_glyphstring): Mark as EXTERNALLY_VISIBLE.
* src/nsfns.m (ns_tooltip, ns_display_info_for_name)
(ns_set_name_as_filename, x_set_menu_bar_lines)
(x_set_tool_bar_lines, x_set_internal_border_width):
* src/nsterm.m (ns_drag_types, ns_draw_text_decoration):
Now static.
* src/nsfns.m (ns_lisp_to_cursor_type, ns_cursor_type_to_lisp):
* src/nsterm.m (ns_free_indexed_color, ns_color_to_lisp):
Remove; unused.
* src/nsfont.m (ns_dump_glyphstring):
* src/nsterm.m (hide_bell, ns_get_color, ns_color_to_lisp)
(ns_clear_frame, keyDown:):
Fix signedness problem with printf arg.
* src/nsterm.h (ns_input_events, ns_finish_events):
* src/nsterm.m (ns_finish_events, hide_bell):
Prototype the decls.
* src/nsterm.m (NSMenuDidBeginTrackingNotification):
Omit unnecessary decl.
(dockMenu):
(mainMenu) [NS_IMPL_COCOA]: Now static, and in this file.
(ns_dumpglyphs_box_or_relief, changeFont:, initFrameFromEmacs:)
(toggleFullScreen:): Use FACE_FROM_ID instead of
FACE_FROM_ID_OR_NULL in contexts where the caller expects the
result to be non-null.
(applicationShouldTerminate:): Fix misleading indentation.
This commit is contained in:
Paul Eggert 2016-09-29 20:09:37 -07:00
parent cbb2e84518
commit 3c2c50260e
8 changed files with 132 additions and 266 deletions

View file

@ -4433,8 +4433,8 @@ XParseGeometry (char *string,
{
int mask = NoValue;
char *strind;
unsigned long tempWidth, tempHeight;
long int tempX, tempY;
unsigned long tempWidth UNINIT, tempHeight UNINIT;
long int tempX UNINIT, tempY UNINIT;
char *nextCharacter;
if (string == NULL || *string == '\0')

View file

@ -97,11 +97,9 @@ typedef struct ns_bitmap_record Bitmap_Record;
#define NO_PIXMAP 0
#define PIX_MASK_RETAIN 0
#define PIX_MASK_DRAW 1
#define x_defined_color(f, name, color_def, alloc) \
ns_defined_color (f, name, color_def, alloc, 0)
#define DefaultDepthOfScreen(screen) x_display_list->n_planes
#endif /* HAVE_NS */
#if (defined HAVE_X_WINDOWS \
@ -2333,12 +2331,12 @@ x_find_image_file (Lisp_Object file)
occurred. FD is a file descriptor open for reading FILE. Set
*SIZE to the size of the file. */
static unsigned char *
static char *
slurp_file (int fd, ptrdiff_t *size)
{
FILE *fp = fdopen (fd, "rb");
unsigned char *buf = NULL;
char *buf = NULL;
struct stat st;
if (fp)
@ -2563,9 +2561,9 @@ xbm_image_p (Lisp_Object object)
scanning a number, store its value in *IVAL. */
static int
xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
xbm_scan (char **s, char *end, char *sval, int *ival)
{
unsigned int c;
unsigned char c;
loop:
@ -2617,7 +2615,7 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
if (*s < end)
*s = *s - 1;
*ival = value;
c = XBM_TK_NUMBER;
return XBM_TK_NUMBER;
}
else if (c_isalpha (c) || c == '_')
{
@ -2628,7 +2626,7 @@ xbm_scan (unsigned char **s, unsigned char *end, char *sval, int *ival)
*sval = 0;
if (*s < end)
*s = *s - 1;
c = XBM_TK_IDENT;
return XBM_TK_IDENT;
}
else if (c == '/' && **s == '*')
{
@ -2765,11 +2763,11 @@ Create_Pixmap_From_Bitmap_Data (struct frame *f, struct image *img, char *data,
bitmap remains unread). */
static bool
xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *end,
xbm_read_bitmap_data (struct frame *f, char *contents, char *end,
int *width, int *height, char **data,
bool inhibit_image_error)
{
unsigned char *s = contents;
char *s = contents;
char buffer[BUFSIZ];
bool padding_p = 0;
bool v10 = 0;
@ -2926,8 +2924,7 @@ xbm_read_bitmap_data (struct frame *f, unsigned char *contents, unsigned char *e
successful. */
static bool
xbm_load_image (struct frame *f, struct image *img, unsigned char *contents,
unsigned char *end)
xbm_load_image (struct frame *f, struct image *img, char *contents, char *end)
{
bool rc;
char *data;
@ -2987,8 +2984,8 @@ xbm_file_p (Lisp_Object data)
{
int w, h;
return (STRINGP (data)
&& xbm_read_bitmap_data (NULL, SDATA (data),
(SDATA (data) + SBYTES (data)),
&& xbm_read_bitmap_data (NULL, SSDATA (data),
SSDATA (data) + SBYTES (data),
&w, &h, NULL, 1));
}
@ -3017,7 +3014,7 @@ xbm_load (struct frame *f, struct image *img)
}
ptrdiff_t size;
unsigned char *contents = slurp_file (fd, &size);
char *contents = slurp_file (fd, &size);
if (contents == NULL)
{
image_error ("Error loading XBM image `%s'", file);
@ -3078,9 +3075,8 @@ xbm_load (struct frame *f, struct image *img)
}
if (in_memory_file_p)
success_p = xbm_load_image (f, img, SDATA (data),
(SDATA (data)
+ SBYTES (data)));
success_p = xbm_load_image (f, img, SSDATA (data),
SSDATA (data) + SBYTES (data));
else
{
USE_SAFE_ALLOCA;
@ -3894,14 +3890,12 @@ xpm_load (struct frame *f, struct image *img)
/* XPM support functions for NS where libxpm is not available.
Only XPM version 3 (without any extensions) is supported. */
static void xpm_put_color_table_v (Lisp_Object, const unsigned char *,
static void xpm_put_color_table_v (Lisp_Object, const char *,
int, Lisp_Object);
static Lisp_Object xpm_get_color_table_v (Lisp_Object,
const unsigned char *, int);
static void xpm_put_color_table_h (Lisp_Object, const unsigned char *,
static Lisp_Object xpm_get_color_table_v (Lisp_Object, const char *, int);
static void xpm_put_color_table_h (Lisp_Object, const char *,
int, Lisp_Object);
static Lisp_Object xpm_get_color_table_h (Lisp_Object,
const unsigned char *, int);
static Lisp_Object xpm_get_color_table_h (Lisp_Object, const char *, int);
/* Tokens returned from xpm_scan. */
@ -3920,12 +3914,9 @@ enum xpm_token
length of the corresponding token, respectively. */
static int
xpm_scan (const unsigned char **s,
const unsigned char *end,
const unsigned char **beg,
ptrdiff_t *len)
xpm_scan (const char **s, const char *end, const char **beg, ptrdiff_t *len)
{
int c;
unsigned char c;
while (*s < end)
{
@ -3988,12 +3979,9 @@ xpm_scan (const unsigned char **s,
hash table is used. */
static Lisp_Object
xpm_make_color_table_v (void (**put_func) (Lisp_Object,
const unsigned char *,
int,
xpm_make_color_table_v (void (**put_func) (Lisp_Object, const char *, int,
Lisp_Object),
Lisp_Object (**get_func) (Lisp_Object,
const unsigned char *,
Lisp_Object (**get_func) (Lisp_Object, const char *,
int))
{
*put_func = xpm_put_color_table_v;
@ -4003,28 +3991,27 @@ xpm_make_color_table_v (void (**put_func) (Lisp_Object,
static void
xpm_put_color_table_v (Lisp_Object color_table,
const unsigned char *chars_start,
const char *chars_start,
int chars_len,
Lisp_Object color)
{
ASET (color_table, *chars_start, color);
unsigned char uc = *chars_start;
ASET (color_table, uc, color);
}
static Lisp_Object
xpm_get_color_table_v (Lisp_Object color_table,
const unsigned char *chars_start,
const char *chars_start,
int chars_len)
{
return AREF (color_table, *chars_start);
unsigned char uc = *chars_start;
return AREF (color_table, uc);
}
static Lisp_Object
xpm_make_color_table_h (void (**put_func) (Lisp_Object,
const unsigned char *,
int,
xpm_make_color_table_h (void (**put_func) (Lisp_Object, const char *, int,
Lisp_Object),
Lisp_Object (**get_func) (Lisp_Object,
const unsigned char *,
Lisp_Object (**get_func) (Lisp_Object, const char *,
int))
{
*put_func = xpm_put_color_table_h;
@ -4037,7 +4024,7 @@ xpm_make_color_table_h (void (**put_func) (Lisp_Object,
static void
xpm_put_color_table_h (Lisp_Object color_table,
const unsigned char *chars_start,
const char *chars_start,
int chars_len,
Lisp_Object color)
{
@ -4051,7 +4038,7 @@ xpm_put_color_table_h (Lisp_Object color_table,
static Lisp_Object
xpm_get_color_table_h (Lisp_Object color_table,
const unsigned char *chars_start,
const char *chars_start,
int chars_len)
{
struct Lisp_Hash_Table *table = XHASH_TABLE (color_table);
@ -4085,20 +4072,22 @@ xpm_str_to_color_key (const char *s)
static bool
xpm_load_image (struct frame *f,
struct image *img,
const unsigned char *contents,
const unsigned char *end)
const char *contents,
const char *end)
{
const unsigned char *s = contents, *beg, *str;
unsigned char buffer[BUFSIZ];
const char *s = contents, *beg, *str;
char buffer[BUFSIZ];
int width, height, x, y;
int num_colors, chars_per_pixel;
ptrdiff_t len;
int LA1;
void (*put_color_table) (Lisp_Object, const unsigned char *, int, Lisp_Object);
Lisp_Object (*get_color_table) (Lisp_Object, const unsigned char *, int);
void (*put_color_table) (Lisp_Object, const char *, int, Lisp_Object);
Lisp_Object (*get_color_table) (Lisp_Object, const char *, int);
Lisp_Object frame, color_symbols, color_table;
int best_key;
#ifndef HAVE_NS
bool have_mask = false;
#endif
XImagePtr ximg = NULL, mask_img = NULL;
#define match() \
@ -4337,7 +4326,7 @@ xpm_load (struct frame *f,
}
ptrdiff_t size;
unsigned char *contents = slurp_file (fd, &size);
char *contents = slurp_file (fd, &size);
if (contents == NULL)
{
image_error ("Error loading XPM image `%s'", file);
@ -4357,8 +4346,8 @@ xpm_load (struct frame *f,
image_error ("Invalid image data `%s'", data);
return 0;
}
success_p = xpm_load_image (f, img, SDATA (data),
SDATA (data) + SBYTES (data));
success_p = xpm_load_image (f, img, SSDATA (data),
SSDATA (data) + SBYTES (data));
}
return success_p;
@ -5051,13 +5040,13 @@ static void
x_build_heuristic_mask (struct frame *f, struct image *img, Lisp_Object how)
{
XImagePtr_or_DC ximg;
#ifndef HAVE_NTGUI
XImagePtr mask_img;
#else
#ifdef HAVE_NTGUI
HGDIOBJ prev;
char *mask_img;
int row_width;
#endif /* HAVE_NTGUI */
#elif !defined HAVE_NS
XImagePtr mask_img;
#endif
int x, y;
bool use_img_background;
unsigned long bg = 0;
@ -5232,20 +5221,22 @@ pbm_image_p (Lisp_Object object)
end of input. */
static int
pbm_next_char (unsigned char **s, unsigned char *end)
pbm_next_char (char **s, char *end)
{
int c = -1;
while (*s < end && (c = *(*s)++, c == '#'))
while (*s < end)
{
/* Skip to the next line break. */
while (*s < end && (c = *(*s)++, c != '\n' && c != '\r'))
;
c = -1;
unsigned char c = *(*s)++;
if (c != '#')
return c;
while (*s < end)
{
c = *(*s)++;
if (c == '\n' || c == '\r')
break;
}
}
return c;
return -1;
}
@ -5254,7 +5245,7 @@ pbm_next_char (unsigned char **s, unsigned char *end)
end of input. */
static int
pbm_scan_number (unsigned char **s, unsigned char *end)
pbm_scan_number (char **s, char *end)
{
int c = 0, val = -1;
@ -5284,12 +5275,9 @@ pbm_load (struct frame *f, struct image *img)
int width, height, max_color_idx = 0;
Lisp_Object specified_file;
enum {PBM_MONO, PBM_GRAY, PBM_COLOR} type;
unsigned char *contents = NULL;
unsigned char *end, *p;
#ifdef USE_CAIRO
unsigned char *data = 0;
uint32_t *dataptr;
#else
char *contents = NULL;
char *end, *p;
#ifndef USE_CAIRO
XImagePtr ximg;
#endif
@ -5325,7 +5313,7 @@ pbm_load (struct frame *f, struct image *img)
image_error ("Invalid image data `%s'", data);
return 0;
}
p = SDATA (data);
p = SSDATA (data);
end = p + SBYTES (data);
}
@ -5376,8 +5364,8 @@ pbm_load (struct frame *f, struct image *img)
height = pbm_scan_number (&p, end);
#ifdef USE_CAIRO
data = (unsigned char *) xmalloc (width * height * 4);
dataptr = (uint32_t *) data;
uint32_t *data = xmalloc (width * height * 4);
uint32_t *dataptr = data;
#endif
if (type != PBM_MONO)
@ -5406,7 +5394,8 @@ pbm_load (struct frame *f, struct image *img)
if (type == PBM_MONO)
{
int c = 0, g;
unsigned char c = 0;
int g;
struct image_keyword fmt[PBM_LAST];
unsigned long fg = FRAME_FOREGROUND_PIXEL (f);
unsigned long bg = FRAME_BACKGROUND_PIXEL (f);
@ -8534,7 +8523,6 @@ imagemagick_load_image (struct frame *f, struct image *img,
EMACS_INT ino;
int desired_width, desired_height;
double rotation;
int pixelwidth;
char hint_buffer[MaxTextExtent];
char *filename_hint = NULL;
@ -8763,7 +8751,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
on rgb display.
seems about 3 times as fast as pixel pushing(not carefully measured)
*/
pixelwidth = CharPixel; /*??? TODO figure out*/
int pixelwidth = CharPixel; /*??? TODO figure out*/
MagickExportImagePixels (image_wand, 0, 0, width, height,
exportdepth, pixelwidth, ximg->data);
}
@ -8947,7 +8935,7 @@ static bool svg_image_p (Lisp_Object object);
static bool svg_load (struct frame *f, struct image *img);
static bool svg_load_image (struct frame *, struct image *,
unsigned char *, ptrdiff_t, char *);
char *, ptrdiff_t, char *);
/* Indices of image specification fields in svg_format, below. */
@ -9155,7 +9143,7 @@ svg_load (struct frame *f, struct image *img)
/* Read the entire file into memory. */
ptrdiff_t size;
unsigned char *contents = slurp_file (fd, &size);
char *contents = slurp_file (fd, &size);
if (contents == NULL)
{
image_error ("Error loading SVG image `%s'", file);
@ -9179,7 +9167,7 @@ svg_load (struct frame *f, struct image *img)
return 0;
}
original_filename = BVAR (current_buffer, filename);
success_p = svg_load_image (f, img, SDATA (data), SBYTES (data),
success_p = svg_load_image (f, img, SSDATA (data), SBYTES (data),
(NILP (original_filename) ? NULL
: SSDATA (original_filename)));
}
@ -9187,19 +9175,16 @@ svg_load (struct frame *f, struct image *img)
return success_p;
}
/* svg_load_image is a helper function for svg_load, which does the
actual loading given contents and size, apart from frame and image
structures, passed from svg_load.
/* Load frame F and image IMG. CONTENTS contains the SVG XML data to
be parsed, SIZE is its size, and FILENAME is the name of the SVG
file being loaded.
Uses librsvg to do most of the image processing.
Use librsvg to do most of the image processing.
Returns true when successful. */
Return true when successful. */
static bool
svg_load_image (struct frame *f, /* Pointer to emacs frame structure. */
struct image *img, /* Pointer to emacs image structure. */
unsigned char *contents, /* String containing the SVG XML data to be parsed. */
ptrdiff_t size, /* Size of data in bytes. */
char *filename) /* Name of SVG file being loaded. */
svg_load_image (struct frame *f, struct image *img, char *contents,
ptrdiff_t size, char *filename)
{
RsvgHandle *rsvg_handle;
RsvgDimensionData dimension_data;
@ -9226,7 +9211,7 @@ svg_load_image (struct frame *f, /* Pointer to emacs frame structure. *
rsvg_handle_set_base_uri(rsvg_handle, filename);
/* Parse the contents argument and fill in the rsvg_handle. */
rsvg_handle_write (rsvg_handle, contents, size, &err);
rsvg_handle_write (rsvg_handle, (unsigned char *) contents, size, &err);
if (err) goto rsvg_error;
/* The parsing is complete, rsvg_handle is ready to used, close it

View file

@ -52,12 +52,7 @@ Updated by Christian Limpach (chris@nice.ch)
#ifdef HAVE_NS
extern NSArray *ns_send_types, *ns_return_types, *ns_drag_types;
EmacsTooltip *ns_tooltip = nil;
/* Need forward declaration here to preserve organizational integrity of file */
Lisp_Object Fx_open_connection (Lisp_Object, Lisp_Object, Lisp_Object);
static EmacsTooltip *ns_tooltip = nil;
/* Static variables to handle applescript execution. */
static Lisp_Object as_script, *as_result;
@ -65,6 +60,8 @@ Updated by Christian Limpach (chris@nice.ch)
static ptrdiff_t image_cache_refcount;
static struct ns_display_info *ns_display_info_for_name (Lisp_Object);
static void ns_set_name_as_filename (struct frame *);
/* ==========================================================================
@ -132,7 +129,7 @@ Updated by Christian Limpach (chris@nice.ch)
/* Return the X display structure for the display named NAME.
Open a new connection if necessary. */
struct ns_display_info *
static struct ns_display_info *
ns_display_info_for_name (Lisp_Object name)
{
struct ns_display_info *dpyinfo;
@ -523,7 +520,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
}
void
static void
ns_set_name_as_filename (struct frame *f)
{
NSView *view;
@ -622,7 +619,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
}
void
static void
x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
{
int nlines;
@ -652,7 +649,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
/* toolbar support */
void
static void
x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
{
/* Currently, when the tool bar change state, the frame is resized.
@ -720,7 +717,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
}
void
static void
x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
int old_width = FRAME_INTERNAL_BORDER_WIDTH (f);
@ -850,40 +847,6 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side
[view setMiniwindowImage: setMini];
}
/* TODO: move to nsterm? */
int
ns_lisp_to_cursor_type (Lisp_Object arg)
{
char *str;
if (XTYPE (arg) == Lisp_String)
str = SSDATA (arg);
else if (XTYPE (arg) == Lisp_Symbol)
str = SSDATA (SYMBOL_NAME (arg));
else return -1;
if (!strcmp (str, "box")) return FILLED_BOX_CURSOR;
if (!strcmp (str, "hollow")) return HOLLOW_BOX_CURSOR;
if (!strcmp (str, "hbar")) return HBAR_CURSOR;
if (!strcmp (str, "bar")) return BAR_CURSOR;
if (!strcmp (str, "no")) return NO_CURSOR;
return -1;
}
Lisp_Object
ns_cursor_type_to_lisp (int arg)
{
switch (arg)
{
case FILLED_BOX_CURSOR: return Qbox;
case HOLLOW_BOX_CURSOR: return Qhollow;
case HBAR_CURSOR: return Qhbar;
case BAR_CURSOR: return Qbar;
case NO_CURSOR:
default: return intern ("no");
}
}
/* This is the same as the xfns.c definition. */
static void
x_set_cursor_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
@ -2273,9 +2236,10 @@ and GNUstep implementations ("distributor-specific release
return NULL;
res = ns_get_defaults_value (toCheck);
return (!res ? NULL :
(!c_strncasecmp (res, "YES", 3) ? "true" :
(!c_strncasecmp (res, "NO", 2) ? "false" : (char *) res)));
return (char *) (!res ? NULL
: !c_strncasecmp (res, "YES", 3) ? "true"
: !c_strncasecmp (res, "NO", 2) ? "false"
: res);
}

View file

@ -45,9 +45,6 @@
#define NSFONT_TRACE 0
#define LCD_SMOOTHING_MARGIN 2
extern float ns_antialias_threshold;
/* font glyph and metrics caching functions, implemented at end */
static void ns_uni_to_glyphs (struct nsfont_info *font_info,
unsigned char block);
@ -1516,7 +1513,10 @@ - (void)setIntAttribute: (NSInteger)attributeTag value: (NSInteger)val
s->nchars, s->x, s->y, s->left_overhang, s->right_overhang,
s->row->overlapping_p, s->background_filled_p);
for (i =0; i<s->nchars; i++)
fprintf (stderr, "%c", s->first_glyph[i].u.ch);
{
int c = s->first_glyph[i].u.ch;
fprintf (stderr, "%c", c);
}
fprintf (stderr, "\n");
}

View file

@ -46,11 +46,11 @@ Updated by Christian Limpach (chris@nice.ch)
========================================================================== */
void *
ns_image_from_XBM (unsigned char *bits, int width, int height,
ns_image_from_XBM (char *bits, int width, int height,
unsigned long fg, unsigned long bg)
{
NSTRACE ("ns_image_from_XBM");
return [[EmacsImage alloc] initFromXBM: bits
return [[EmacsImage alloc] initFromXBM: (unsigned char *) bits
width: width height: height
fg: fg bg: bg];
}

View file

@ -53,8 +53,7 @@
#endif
extern long context_menu_value;
EmacsMenu *mainMenu, *svcsMenu, *dockMenu;
EmacsMenu *svcsMenu;
/* Nonzero means a menu is currently active. */
static int popup_activated_flag;

View file

@ -731,7 +731,7 @@ char const * nstrace_fullscreen_type_name (int);
extern NSArray *ns_send_types, *ns_return_types;
extern NSString *ns_app_name;
extern EmacsMenu *mainMenu, *svcsMenu, *dockMenu;
extern EmacsMenu *svcsMenu;
/* Apple removed the declaration, but kept the implementation */
#if defined (NS_IMPL_COCOA)
@ -924,8 +924,6 @@ struct ns_display_info
/* This is a chain of structures for all the NS displays currently in use. */
extern struct ns_display_info *x_display_list;
extern struct ns_display_info *ns_display_info_for_name (Lisp_Object name);
struct ns_output
{
#ifdef __OBJC__
@ -1099,7 +1097,7 @@ extern void nsfont_make_fontset_for_font (Lisp_Object name,
/* In nsfont, for debugging */
struct glyph_string;
void ns_dump_glyphstring (struct glyph_string *s);
void ns_dump_glyphstring (struct glyph_string *s) EXTERNALLY_VISIBLE;
/* Implemented in nsterm, published in or needed from nsfns. */
extern Lisp_Object ns_list_fonts (struct frame *f, Lisp_Object pattern,
@ -1116,9 +1114,6 @@ extern void ns_string_to_pasteboard (id pb, Lisp_Object str);
extern Lisp_Object ns_get_local_selection (Lisp_Object selection_name,
Lisp_Object target_type);
extern void nxatoms_of_nsselect (void);
extern int ns_lisp_to_cursor_type (Lisp_Object arg);
extern Lisp_Object ns_cursor_type_to_lisp (int arg);
extern void ns_set_name_as_filename (struct frame *f);
extern void ns_set_doc_edited (void);
extern bool
@ -1130,11 +1125,9 @@ extern void
ns_query_color (void *col, XColor *color_def, int setPixel);
#ifdef __OBJC__
extern Lisp_Object ns_color_to_lisp (NSColor *col);
extern int ns_lisp_to_color (Lisp_Object color, NSColor **col);
extern NSColor *ns_lookup_indexed_color (unsigned long idx, struct frame *f);
extern unsigned long ns_index_color (NSColor *color, struct frame *f);
extern void ns_free_indexed_color (unsigned long idx, struct frame *f);
extern const char *ns_get_pending_menu_title (void);
extern void ns_check_menu_open (NSMenu *menu);
extern void ns_check_pending_open_menu (void);
@ -1152,8 +1145,6 @@ extern void ns_init_locale (void);
/* in nsmenu */
extern void update_frame_tool_bar (struct frame *f);
extern void free_frame_tool_bar (struct frame *f);
extern void find_and_call_menu_selection (struct frame *f,
int menu_bar_items_used, Lisp_Object vector, void *client_data);
extern Lisp_Object find_and_return_menu_selection (struct frame *f,
bool keymaps,
void *client_data);
@ -1176,7 +1167,7 @@ extern void syms_of_nsselect (void);
/* From nsimage.m, needed in image.c */
struct image;
extern void *ns_image_from_XBM (unsigned char *bits, int width, int height,
extern void *ns_image_from_XBM (char *bits, int width, int height,
unsigned long fg, unsigned long bg);
extern void *ns_image_for_XPM (int width, int height, int depth);
extern void *ns_image_from_file (Lisp_Object file);
@ -1192,6 +1183,7 @@ extern int x_display_pixel_height (struct ns_display_info *);
extern int x_display_pixel_width (struct ns_display_info *);
/* This in nsterm.m */
extern float ns_antialias_threshold;
extern void x_destroy_window (struct frame *f);
extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timespec const *timeout,
@ -1199,14 +1191,11 @@ extern int ns_select (int nfds, fd_set *readfds, fd_set *writefds,
extern unsigned long ns_get_rgb_color (struct frame *f,
float r, float g, float b, float a);
extern void ns_init_events ();
extern void ns_finish_events ();
struct input_event;
extern void ns_init_events (struct input_event *);
extern void ns_finish_events (void);
#ifdef __OBJC__
/* From nsterm.m, needed in nsfont.m. */
extern void
ns_draw_text_decoration (struct glyph_string *s, struct face *face,
NSColor *defaultCol, CGFloat width, CGFloat x);
/* Needed in nsfns.m. */
extern void
ns_set_represented_filename (NSString* fstr, struct frame *f);

View file

@ -68,9 +68,10 @@ Updated by Christian Limpach (chris@nice.ch)
#include "macfont.h"
#endif
extern NSString *NSMenuDidBeginTrackingNotification;
static EmacsMenu *dockMenu;
#ifdef NS_IMPL_COCOA
static EmacsMenu *mainMenu;
#endif
/* ==========================================================================
@ -255,7 +256,8 @@ - (NSColor *)colorUsingDefaultColorSpace
no way to control this behavior. */
float ns_antialias_threshold;
NSArray *ns_send_types =0, *ns_return_types =0, *ns_drag_types =0;
NSArray *ns_send_types = 0, *ns_return_types = 0;
static NSArray *ns_drag_types = 0;
NSString *ns_app_name = @"Emacs"; /* default changed later */
/* Display variables */
@ -413,7 +415,6 @@ - (NSColor *)colorUsingDefaultColorSpace
/* TODO: get rid of need for these forward declarations */
static void ns_condemn_scroll_bars (struct frame *f);
static void ns_judge_scroll_bars (struct frame *f);
void x_set_frame_alpha (struct frame *f);
/* ==========================================================================
@ -437,7 +438,7 @@ - (NSColor *)colorUsingDefaultColorSpace
}
void
ns_finish_events ()
ns_finish_events (void)
{
emacs_event = NULL;
}
@ -1423,7 +1424,8 @@ -(void)remove
}
static void hide_bell ()
static void
hide_bell (void)
/* --------------------------------------------------------------------------
Ensure the bell is hidden.
-------------------------------------------------------------------------- */
@ -1897,37 +1899,6 @@ static void hide_bell ()
}
void
ns_free_indexed_color (unsigned long idx, struct frame *f)
{
struct ns_color_table *color_table;
NSColor *color;
NSNumber *index;
if (!f)
return;
color_table = FRAME_DISPLAY_INFO (f)->color_table;
if (idx <= 0 || idx >= color_table->size) {
message1 ("ns_free_indexed_color: Color index out of range.\n");
return;
}
index = [NSNumber numberWithUnsignedInt: idx];
if ([color_table->empty_indices containsObject: index]) {
message1 ("ns_free_indexed_color: attempt to free already freed color.\n");
return;
}
color = color_table->colors[idx];
[color release];
color_table->colors[idx] = nil;
[color_table->empty_indices addObject: index];
/*fprintf(stderr, "color_table: FREED %d\n",idx);*/
}
static int
ns_get_color (const char *name, NSColor **col)
/* --------------------------------------------------------------------------
@ -2009,7 +1980,7 @@ static void hide_bell ()
if (hex[0])
{
int rr, gg, bb;
unsigned int rr, gg, bb;
float fscale = scaling == 4 ? 65535.0 : (scaling == 2 ? 255.0 : 15.0);
if (sscanf (hex, "%x/%x/%x", &rr, &gg, &bb))
{
@ -2074,46 +2045,6 @@ static void hide_bell ()
}
Lisp_Object
ns_color_to_lisp (NSColor *col)
/* --------------------------------------------------------------------------
Convert a color to a lisp string with the RGB equivalent
-------------------------------------------------------------------------- */
{
EmacsCGFloat red, green, blue, alpha, gray;
char buf[1024];
const char *str;
NSTRACE ("ns_color_to_lisp");
block_input ();
if ([[col colorSpaceName] isEqualToString: NSNamedColorSpace])
if ((str =[[col colorNameComponent] UTF8String]))
{
unblock_input ();
return build_string ((char *)str);
}
[[col colorUsingDefaultColorSpace]
getRed: &red green: &green blue: &blue alpha: &alpha];
if (red == green && red == blue)
{
[[col colorUsingColorSpaceName: NSCalibratedWhiteColorSpace]
getWhite: &gray alpha: &alpha];
snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
lrint (gray * 0xff), lrint (gray * 0xff), lrint (gray * 0xff));
unblock_input ();
return build_string (buf);
}
snprintf (buf, sizeof (buf), "#%2.2lx%2.2lx%2.2lx",
lrint (red*0xff), lrint (green*0xff), lrint (blue*0xff));
unblock_input ();
return build_string (buf);
}
void
ns_query_color(void *col, XColor *color_def, int setPixel)
/* --------------------------------------------------------------------------
@ -2462,7 +2393,8 @@ static void hide_bell ()
block_input ();
ns_focus (f, &r, 1);
[ns_lookup_indexed_color (NS_FACE_BACKGROUND (FRAME_DEFAULT_FACE (f)), f) set];
[ns_lookup_indexed_color (NS_FACE_BACKGROUND
(FACE_FROM_ID (f, DEFAULT_FACE_ID)), f) set];
NSRectFill (r);
ns_unfocus (f);
@ -3074,7 +3006,7 @@ Note that CURSOR_WIDTH is meaningful only for (h)bar cursors.
void
static void
ns_draw_text_decoration (struct glyph_string *s, struct face *face,
NSColor *defaultCol, CGFloat width, CGFloat x)
/* --------------------------------------------------------------------------
@ -3317,7 +3249,7 @@ Function modeled after x_draw_glyph_string_box ().
face = FACE_FROM_ID_OR_NULL (s->f,
MOUSE_HL_INFO (s->f)->mouse_face_face_id);
if (!face)
face = FACE_FROM_ID_OR_NULL (s->f, MOUSE_FACE_ID);
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
}
else
face = s->face;
@ -5433,15 +5365,11 @@ - (NSApplicationTerminateReply)applicationShouldTerminate: (id)sender
if (NILP (ns_confirm_quit)) // || ns_shutdown_properly --> TO DO
return NSTerminateNow;
ret = runAlertPanel(ns_app_name,
@"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?",
@"Save Buffers and Exit", @"Cancel");
ret = runAlertPanel(ns_app_name,
@"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?",
@"Save Buffers and Exit", @"Cancel");
if (ret)
return NSTerminateNow;
else
return NSTerminateCancel;
return NSTerminateNow; /* just in case */
return ret ? NSTerminateNow : NSTerminateCancel;
}
static int
@ -5722,7 +5650,7 @@ - (void)dealloc
- (void)changeFont: (id)sender
{
NSEvent *e = [[self window] currentEvent];
struct face *face = FRAME_DEFAULT_FACE (emacsframe);
struct face *face = FACE_FROM_ID (emacsframe, DEFAULT_FACE_ID);
struct font *font = face->font;
id newFont;
CGFloat size;
@ -5992,7 +5920,7 @@ flag set (this is probably a bug in the OS).
if (NS_KEYLOG)
fprintf (stderr, "keyDown: code =%x\tfnKey =%x\tflags = %x\tmods = %x\n",
code, fnKeysym, flags, emacs_event->modifiers);
(unsigned) code, fnKeysym, flags, emacs_event->modifiers);
/* if it was a function key or had modifiers, pass it directly to emacs */
if (fnKeysym || (emacs_event->modifiers
@ -6930,7 +6858,8 @@ This avoids an extra clear and redraw (flicker) at frame creation. */
[win makeFirstResponder: self];
col = ns_lookup_indexed_color (NS_FACE_BACKGROUND
(FRAME_DEFAULT_FACE (emacsframe)), emacsframe);
(FACE_FROM_ID (emacsframe, DEFAULT_FACE_ID)),
emacsframe);
[win setBackgroundColor: col];
if ([col alphaComponent] != (EmacsCGFloat) 1.0)
[win setOpaque: NO];
@ -7332,7 +7261,7 @@ - (void)toggleFullScreen: (id)sender
f = emacsframe;
wr = [w frame];
col = ns_lookup_indexed_color (NS_FACE_BACKGROUND
(FRAME_DEFAULT_FACE (f)),
(FACE_FROM_ID (f, DEFAULT_FACE_ID)),
f);
if (fs_state != FULLSCREEN_BOTH)
@ -8394,7 +8323,7 @@ - (void)mouseDown: (NSEvent *)e
NSRect sr, kr;
/* hitPart is only updated AFTER event is passed on */
NSScrollerPart part = [self testPart: [e locationInWindow]];
CGFloat inc = 0.0, loc, kloc, pos;
CGFloat loc, kloc, pos UNINIT;
int edge = 0;
NSTRACE ("[EmacsScroller mouseDown:]");