void describe_gc_cache(struct gc_cache *cache) { int count = 0; struct gc_cache_cell *cell = cache->head; stderr_out("\nsize: %d", cache->size); stderr_out("\ncreated: %d", cache->create_count); stderr_out("\ndeleted: %d", cache->delete_count); while (cell) { struct gc_cache_cell *cell2; int i = 0; stderr_out("\n%d:\t0x%lx GC: 0x%08lx hash: 0x%08lx\n", count, (long)cell, (long)cell->gc, gc_cache_hash(&cell->gcvm)); for (cell2 = cache->head; cell2; cell2 = cell2->next, i++) if (count != i && gc_cache_hash(&cell->gcvm) == gc_cache_hash(&cell2->gcvm)) stderr_out("\tHASH COLLISION with cell %d\n", i); stderr_out("\tmask: %8lx\n", cell->gcvm.mask); #define FROB(field) do { \ if ((int)cell->gcvm.gcv.field != (~0)) \ stderr_out ("\t%-12s%8x\n", #field ":", (int)cell->gcvm.gcv.field); \ } while (0) FROB(function); FROB(plane_mask); FROB(foreground); FROB(background); FROB(line_width); FROB(line_style); FROB(cap_style); FROB(join_style); FROB(fill_style); FROB(fill_rule); FROB(arc_mode); FROB(tile); FROB(stipple); FROB(ts_x_origin); FROB(ts_y_origin); FROB(font); FROB(subwindow_mode); FROB(graphics_exposures); FROB(clip_x_origin); FROB(clip_y_origin); FROB(clip_mask); FROB(dash_offset); #undef FROB count++; if (cell->next && cell == cache->tail) stderr_out("\nERROR! tail is here!\n\n"); else if (!cell->next && cell != cache->tail) stderr_out("\nERROR! tail is not at the end\n\n"); cell = cell->next; } if (count != cache->size) stderr_out("\nERROR! count should be %d\n\n", cache->size); }
int poll_fds_for_input (SELECT_TYPE mask) { EMACS_TIME sometime; EMACS_SELECT_TIME select_time; SELECT_TYPE temp_mask; int retval; while (1) { EMACS_SET_SECS_USECS (sometime, 0, 0); EMACS_TIME_TO_SELECT_TIME (sometime, select_time); temp_mask = mask; /* To effect a poll, tell select() to block for zero seconds. */ retval = select (MAXDESC, &temp_mask, 0, 0, &select_time); if (retval >= 0) return retval; if (errno != EINTR) { /* Something went seriously wrong; don't ABORT since maybe the TTY just died at the wrong time. */ stderr_out ("xemacs: select failed: errno = %d\n", errno); return 0; } /* else, we got interrupted by a signal, so try again. */ } RETURN_NOT_REACHED(0) /* not reached */ }
void Initialize_Locale (void) { char *locale; /* dverna - Nov. 98: #### DON'T DO THIS !!! The default XtLanguageProc routine calls setlocale(LC_ALL, lang) which f***s up our lower-level locale management, and especially the value of LC_NUMERIC. Anyway, since at this point, we don't know yet whether we're gonna need an X11 frame, we should really do it manually and not use Xlib's dumb default routine */ /*XtSetLanguageProc (NULL, (XtLanguageProc) NULL, NULL);*/ if ((locale = setlocale (LC_ALL, "")) == NULL) { stderr_out ("Can't set locale.\n"); stderr_out ("Using C locale instead.\n"); putenv ("LANG=C"); putenv ("LC_ALL=C"); if ((locale = setlocale (LC_ALL, "C")) == NULL) { stderr_out ("Can't even set locale to `C'!\n"); return; } } if (!XSupportsLocale ()) { stderr_out ("X Windows does not support locale `%s'\n", locale); stderr_out ("Using C Locale instead\n"); putenv ("LANG=C"); putenv ("LC_ALL=C"); if ((locale = setlocale (LC_ALL, "C")) == NULL) { stderr_out ("Can't even set locale to `C'!\n"); return; } if (!XSupportsLocale ()) { stderr_out ("X Windows does not even support locale `C'!\n"); return; } } setlocale(LC_NUMERIC, "C"); if (XSetLocaleModifiers ("") == NULL) { stderr_out ("XSetLocaleModifiers(\"\") failed\n"); stderr_out ("Check the value of the XMODIFIERS environment variable.\n"); } }
static void setup_context_cache (struct buffer *buf, Bufpos pt) { int recomputed_start_point = 0; /* This function can GC */ if (context_cache.buffer != buf || pt < context_cache.start_point) { start_over: if (font_lock_debug) stderr_out ("reset context cache\n"); /* OK, completely invalid. */ reset_context_cache (&context_cache); reset_context_cache (&bol_context_cache); } if (!context_cache.buffer) { /* Need to recompute the start point. */ if (font_lock_debug) stderr_out ("recompute start\n"); context_cache.start_point = beginning_of_defun (buf, pt); recomputed_start_point = 1; bol_context_cache.start_point = context_cache.start_point; bol_context_cache.buffer = context_cache.buffer = buf; } if (context_cache.end_point < context_cache.start_point) { /* Need to recompute the end point. */ if (font_lock_debug) stderr_out ("recompute end\n"); context_cache.end_point = end_of_defun (buf, context_cache.start_point); bol_context_cache.end_point = context_cache.end_point; } if (bol_context_cache.cur_point == 0 || pt < bol_context_cache.cur_point) { if (font_lock_debug) stderr_out ("reset to start\n"); if (pt > context_cache.end_point /* 3000 is some arbitrary delta but seems reasonable; about the size of a reasonable function */ && pt - context_cache.end_point > 3000) /* If we're far past the end of the top level form, don't trust it; recompute it. */ { /* But don't get in an infinite loop doing this. If we're really far past the end of the top level form, try to compute a pseudo-top-level form. */ if (recomputed_start_point) context_cache.needs_its_head_reexamined = 1; else /* force recomputation */ goto start_over; } /* Go to the nearest end of the top-level form that's before us. */ if (pt > context_cache.end_point) pt = context_cache.end_point; else pt = context_cache.start_point; /* Reset current point to start of buffer. */ context_cache.cur_point = pt; context_cache.context = context_none; context_cache.ccontext = ccontext_none; context_cache.style = comment_style_none; context_cache.scontext = '\000'; context_cache.depth = 0; /* #### shouldn't this be checking the character's syntax instead of explicitly testing for backslash characters? */ context_cache.backslash_p = ((pt > 1) && (BUF_FETCH_CHAR (buf, pt - 1) == '\\')); /* Note that the BOL context cache may not be at the beginning of the line, but that should be OK, nobody's checking. */ bol_context_cache = context_cache; return; } else if (pt < context_cache.cur_point) { if (font_lock_debug) stderr_out ("reset to bol\n"); /* bol cache is OK but current_cache is not. */ context_cache = bol_context_cache; return; } else if (pt <= context_cache.end_point) { if (font_lock_debug) stderr_out ("everything is OK\n"); /* in same top-level form. */ return; } { /* OK, we're past the end of the top-level form. */ Bufpos maxpt = max (context_cache.end_point, context_cache.cur_point); #if 0 int shortage; #endif if (font_lock_debug) stderr_out ("past end\n"); if (pt <= maxpt) /* OK, fine. */ return; #if 0 /* This appears to cause huge slowdowns in files which have no top-level forms. In any case, it's not really necessary that we know for sure the top-level form we're in; if we're in a form but the form we have recorded is the previous one, it will be OK. */ scan_buffer (buf, '\n', maxpt, pt, 1, &shortage, 1); if (!shortage) /* If there was a newline in the region past the known universe, we might be inside another top-level form, so start over. Otherwise, we're outside of any top-level forms and we know the one directly before us, so it's OK. */ goto start_over; #endif } }
void font_lock_maybe_update_syntactic_caches (struct buffer *buf, Bufpos start, Bufpos orig_end, Bufpos new_end) { /* Note: either both context_cache and bol_context_cache are valid and point to the same buffer, or both are invalid. If we have to invalidate just context_cache, we recopy it from bol_context_cache. */ if (context_cache.buffer != buf) /* caches don't apply */ return; /* NOTE: The order of the if statements below is important. If you change them around unthinkingly, you will probably break something. */ if (orig_end <= context_cache.start_point - 1) { /* case 1: before the beginning of the current top-level form */ Charcount diff = new_end - orig_end; if (font_lock_debug) stderr_out ("font-lock; Case 1\n"); context_cache.start_point += diff; context_cache.cur_point += diff; context_cache.end_point += diff; bol_context_cache.start_point += diff; bol_context_cache.cur_point += diff; bol_context_cache.end_point += diff; } else if (start <= context_cache.start_point) { if (font_lock_debug) stderr_out ("font-lock; Case 2\n"); /* case 2: right at the current top-level form (paren that starts top level form got deleted or moved away from the newline it was touching) */ reset_context_cache (&context_cache); reset_context_cache (&bol_context_cache); } /* OK, now we know that the start is after the beginning of the current top-level form. */ else if (start < bol_context_cache.cur_point) { if (font_lock_debug) stderr_out ("font-lock; Case 3 (1)\n"); /* case 3: after the beginning of the current top-level form and before both of the caches */ reset_context_cache (&context_cache); reset_context_cache (&bol_context_cache); } else if (start < context_cache.cur_point) { if (font_lock_debug) stderr_out ("font-lock; Case 3 (2)\n"); /* case 3: but only need to invalidate one cache */ context_cache = bol_context_cache; } /* OK, now we know that the start is after the caches. */ else if (start >= context_cache.end_point) { if (font_lock_debug) stderr_out ("font-lock; Case 6\n"); /* case 6: after the end of the current top-level form and after the caches. */ } else if (orig_end <= context_cache.end_point - 2) { /* case 4: after the caches and before the end of the current top-level form */ Charcount diff = new_end - orig_end; if (font_lock_debug) stderr_out ("font-lock; Case 4\n"); context_cache.end_point += diff; bol_context_cache.end_point += diff; } else { if (font_lock_debug) stderr_out ("font-lock; Case 5\n"); /* case 5: right at the end of the current top-level form */ context_cache.end_point = context_cache.start_point - 1; bol_context_cache.end_point = context_cache.start_point - 1; } }
void XIM_init_frame (struct frame *f) { Widget w = FRAME_X_TEXT_WIDGET (f); XPoint spot = {0,0}; XmFontList fontlist; XmFontListEntry fontlistEntry; typedef struct { XFontSet fontset; Pixel fg; Pixel bg; } xim_resources_t; xim_resources_t xim_resources; /* mrb: #### Fix so that background and foreground is set from default face, rather than foreground and background resources, or that the user can use set-frame-parameters to set xic attributes */ #define res(name, class, representation, field, default_value) \ { name, class, representation, sizeof(xim_resources.field), \ XtOffsetOf(xim_resources_t, field), \ XtRString, (XtPointer) (default_value) } static XtResource resources[] = { /* name class represent'n field default value */ res(XtNfontSet, XtCFontSet, XtRFontSet, fontset, XtDefaultFontSet), res(XtNximForeground, XtCForeground, XtRPixel, fg, XtDefaultForeground), res(XtNximBackground, XtCBackground, XtRPixel, bg, XtDefaultBackground) }; XtGetApplicationResources (w, &xim_resources, resources, XtNumber (resources), NULL, 0); if (! xim_resources.fontset) { stderr_out ("Can't get fontset resource for Input Method\n"); return; } fontlistEntry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG, XmFONT_IS_FONTSET, (XtPointer) xim_resources.fontset); fontlist = XmFontListAppendEntry (NULL, fontlistEntry); XmImRegister (w, 0); XmImVaSetValues (w, XmNfontList, fontlist, XmNforeground, xim_resources.fg, XmNbackground, xim_resources.bg, XmNspotLocation, &spot, /* XmNlineSpace, 0, */ NULL); XmFontListEntryFree (&fontlistEntry); XtAddCallback (w, XmNdestroyCallback, XIM_delete_frame, (XtPointer) w); }