summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-06-24 23:01:23 +0000
committerBram Moolenaar <Bram@vim.org>2005-06-24 23:01:23 +0000
commit0a5fe2140db2e6688a7ef42031a21d8293038715 (patch)
treec4a543636157a7e148ef789201f0f6373f8b548e
parentc4def13f8bc6631add3b10bb84783acca72795ae (diff)
updated for version 7.0092
-rw-r--r--runtime/indent/pyrex.vim7
-rw-r--r--runtime/spell/en.ascii.splbin559923 -> 198011 bytes
-rw-r--r--src/Makefile8
-rw-r--r--src/ex_docmd.c7
-rw-r--r--src/fileio.c13
-rw-r--r--src/message.c28
-rw-r--r--src/os_unix.c23
-rw-r--r--src/proto/ex_docmd.pro1
-rw-r--r--src/proto/ex_getln.pro1
-rw-r--r--src/proto/message.pro2
-rw-r--r--src/proto/ops.pro1
-rw-r--r--src/proto/syntax.pro3
-rw-r--r--src/spell.c94
-rw-r--r--src/window.c52
14 files changed, 190 insertions, 50 deletions
diff --git a/runtime/indent/pyrex.vim b/runtime/indent/pyrex.vim
index e7771264ea..a1a1746672 100644
--- a/runtime/indent/pyrex.vim
+++ b/runtime/indent/pyrex.vim
@@ -2,7 +2,12 @@
" Language: Pyrex
" Maintainer: Marco Barisione <marco.bari@people.it>
" URL: http://marcobari.altervista.org/pyrex_vim.html
-" Last Change: 2004 May 16
+" Last Change: 2005 Jun 24
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
" Use Python formatting rules
runtime! indent/python.vim
diff --git a/runtime/spell/en.ascii.spl b/runtime/spell/en.ascii.spl
index 54630e7a6c..739899cd1d 100644
--- a/runtime/spell/en.ascii.spl
+++ b/runtime/spell/en.ascii.spl
Binary files differ
diff --git a/src/Makefile b/src/Makefile
index f27e20d1ea..03ee7c28b7 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -533,6 +533,14 @@ LINT_OPTIONS = -beprxzF
#PROFILE_CFLAGS = -pg -g
#PROFILE_LIBS = -pg
+# MEMORY LEAK DETECTION
+# Requires installing the ccmalloc library.
+# Configuration is in the .ccmalloc file.
+# Doesn't work very well, since memory linked to from global variables
+# (indirectly) is also marked as leaked memory.
+#PROFILE_CFLAGS = -DEXITFREE
+#PROFILE_LIBS = -lccmalloc
+
#####################################################
### Specific systems, check if yours is listed! ### {{{
#####################################################
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index fa94424f62..af3e7f9bfe 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -46,7 +46,6 @@ static garray_T ucmds = {0, 0, sizeof(ucmd_T), 4, NULL};
static void do_ucmd __ARGS((exarg_T *eap));
static void ex_command __ARGS((exarg_T *eap));
-static void ex_comclear __ARGS((exarg_T *eap));
static void ex_delcommand __ARGS((exarg_T *eap));
# ifdef FEAT_CMDL_COMPL
static char_u *get_user_command_name __ARGS((int idx));
@@ -5390,12 +5389,10 @@ ex_command(eap)
/*
* ":comclear"
- */
-/*ARGSUSED*/
-/*
* Clear all user commands, global and for current buffer.
*/
- static void
+/*ARGSUSED*/
+ void
ex_comclear(eap)
exarg_T *eap;
{
diff --git a/src/fileio.c b/src/fileio.c
index 9ae69cf106..dd42fb4cf9 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -7093,6 +7093,17 @@ do_augroup(arg, del_group)
}
}
+#if defined(EXITFREE) || defined(PROTO)
+ void
+free_all_autocmds()
+{
+ for (current_augroup = -1; current_augroup < augroups.ga_len;
+ ++current_augroup)
+ do_autocmd((char_u *)"", TRUE);
+ ga_clear_strings(&augroups);
+}
+#endif
+
/*
* Return the event number for event name "start".
* Return NUM_EVENTS if the event name was not found.
@@ -7632,9 +7643,9 @@ do_autocmd_event(event, pat, nested, cmd, forceit, group)
&ap->allow_dirs, TRUE);
if (reg_pat != NULL)
ap->reg_prog = vim_regcomp(reg_pat, RE_MAGIC);
+ vim_free(reg_pat);
if (reg_pat == NULL || ap->reg_prog == NULL)
{
- vim_free(reg_pat);
vim_free(ap->pat);
vim_free(ap);
return FAIL;
diff --git a/src/message.c b/src/message.c
index 535d65a51a..a43cb9287f 100644
--- a/src/message.c
+++ b/src/message.c
@@ -743,13 +743,8 @@ add_msg_hist(s, len, attr)
/* Don't let the message history get too big */
while (msg_hist_len > 20)
- {
- p = first_msg_hist;
- first_msg_hist = p->next;
- vim_free(p->msg);
- vim_free(p);
- --msg_hist_len;
- }
+ (void)delete_first_msg();
+
/* allocate an entry and add the message at the end of the history */
p = (struct msg_hist *)alloc((int)sizeof(struct msg_hist));
if (p != NULL)
@@ -777,6 +772,25 @@ add_msg_hist(s, len, attr)
}
/*
+ * Delete the first (oldest) message from the history.
+ * Returns FAIL if there are no messages.
+ */
+ int
+delete_first_msg()
+{
+ struct msg_hist *p;
+
+ if (msg_hist_len <= 0)
+ return FAIL;
+ p = first_msg_hist;
+ first_msg_hist = p->next;
+ vim_free(p->msg);
+ vim_free(p);
+ --msg_hist_len;
+ return OK;
+}
+
+/*
* ":messages" command.
*/
/*ARGSUSED*/
diff --git a/src/os_unix.c b/src/os_unix.c
index ba74a2de13..d27b05a6d3 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2699,6 +2699,24 @@ mch_early_init()
#endif
}
+#if defined(EXITFREE) || defined(PROTO)
+ void
+mch_free_mem()
+{
+# if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK)
+ vim_free(signal_stack);
+# endif
+# if (defined(FEAT_X11) && defined(FEAT_XCLIPBOARD)) || defined(PROTO)
+ if (xterm_Shell != (Widget)0)
+ XtDestroyWidget(xterm_Shell);
+ if (xterm_dpy != NULL)
+ XtCloseDisplay(xterm_dpy);
+ if (app_context != (XtAppContext)NULL)
+ XtDestroyApplicationContext(app_context);
+# endif
+}
+#endif
+
static void exit_scroll __ARGS((void));
/*
@@ -2796,6 +2814,11 @@ mch_exit(r)
if (usingNetbeans)
netbeans_send_disconnect();
#endif
+
+#ifdef EXITFREE
+ free_all_mem();
+#endif
+
exit(r);
}
diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro
index 9a0fd2b3c3..3a8200e38d 100644
--- a/src/proto/ex_docmd.pro
+++ b/src/proto/ex_docmd.pro
@@ -15,6 +15,7 @@ int ends_excmd __ARGS((int c));
char_u *find_nextcmd __ARGS((char_u *p));
char_u *check_nextcmd __ARGS((char_u *p));
char_u *get_command_name __ARGS((expand_T *xp, int idx));
+void ex_comclear __ARGS((exarg_T *eap));
void uc_clear __ARGS((garray_T *gap));
char_u *get_user_commands __ARGS((expand_T *xp, int idx));
char_u *get_user_cmd_flags __ARGS((expand_T *xp, int idx));
diff --git a/src/proto/ex_getln.pro b/src/proto/ex_getln.pro
index 97d3c2f7fd..688eb3d8f0 100644
--- a/src/proto/ex_getln.pro
+++ b/src/proto/ex_getln.pro
@@ -25,6 +25,7 @@ void set_cmd_context __ARGS((expand_T *xp, char_u *str, int len, int col));
int expand_cmdline __ARGS((expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches));
int ExpandGeneric __ARGS((expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, char_u *((*func)(expand_T *, int))));
char_u *globpath __ARGS((char_u *path, char_u *file));
+void init_history __ARGS((void));
int get_histtype __ARGS((char_u *name));
void add_to_history __ARGS((int histype, char_u *new_entry, int in_map, int sep));
int get_history_idx __ARGS((int histype));
diff --git a/src/proto/message.pro b/src/proto/message.pro
index f6b29a296f..d76182d91f 100644
--- a/src/proto/message.pro
+++ b/src/proto/message.pro
@@ -11,6 +11,7 @@ int emsg2 __ARGS((char_u *s, char_u *a1));
void emsg_invreg __ARGS((int name));
char_u *msg_trunc_attr __ARGS((char_u *s, int force, int attr));
char_u *msg_may_trunc __ARGS((int force, char_u *s));
+int delete_first_msg __ARGS((void));
void ex_messages __ARGS((exarg_T *eap));
void msg_end_prompt __ARGS((void));
void wait_return __ARGS((int redraw));
@@ -34,7 +35,6 @@ void str2specialbuf __ARGS((char_u *sp, char_u *buf, int len));
void msg_prt_line __ARGS((char_u *s, int list));
void msg_puts __ARGS((char_u *s));
void msg_puts_title __ARGS((char_u *s));
-void msg_puts_long __ARGS((char_u *longstr));
void msg_puts_long_attr __ARGS((char_u *longstr, int attr));
void msg_puts_long_len_attr __ARGS((char_u *longstr, int len, int attr));
void msg_puts_attr __ARGS((char_u *s, int attr));
diff --git a/src/proto/ops.pro b/src/proto/ops.pro
index 5952b951e3..da9973bbe3 100644
--- a/src/proto/ops.pro
+++ b/src/proto/ops.pro
@@ -29,6 +29,7 @@ int swapchar __ARGS((int op_type, pos_T *pos));
void op_insert __ARGS((oparg_T *oap, long count1));
int op_change __ARGS((oparg_T *oap));
void init_yank __ARGS((void));
+void clear_registers __ARGS((void));
int op_yank __ARGS((oparg_T *oap, int deleting, int mess));
void do_put __ARGS((int regname, int dir, long count, int flags));
int preprocs_left __ARGS((void));
diff --git a/src/proto/syntax.pro b/src/proto/syntax.pro
index 3a29674bd7..967d88ed3a 100644
--- a/src/proto/syntax.pro
+++ b/src/proto/syntax.pro
@@ -15,13 +15,14 @@ int syn_get_foldlevel __ARGS((win_T *wp, long lnum));
void init_highlight __ARGS((int both, int reset));
int load_colors __ARGS((char_u *name));
void do_highlight __ARGS((char_u *line, int forceit, int init));
+void free_highlight __ARGS((void));
void restore_cterm_colors __ARGS((void));
void set_normal_colors __ARGS((void));
char_u *hl_get_font_name __ARGS((void));
void hl_set_font_name __ARGS((char_u *font_name));
void hl_set_bg_color_name __ARGS((char_u *name));
void hl_set_fg_color_name __ARGS((char_u *name));
-int hl_combine_attr __ARGS((int char_attr, int spell_attr));
+int hl_combine_attr __ARGS((int char_attr, int prim_attr));
attrentry_T *syn_gui_attr2entry __ARGS((int attr));
attrentry_T *syn_term_attr2entry __ARGS((int attr));
attrentry_T *syn_cterm_attr2entry __ARGS((int attr));
diff --git a/src/spell.c b/src/spell.c
index 4ff413a714..c5d81229e7 100644
--- a/src/spell.c
+++ b/src/spell.c
@@ -2098,6 +2098,7 @@ did_set_spelllang(buf)
garray_T ga;
char_u *splp;
char_u *region;
+ int filename;
int region_mask;
slang_T *lp;
int c;
@@ -2125,34 +2126,55 @@ did_set_spelllang(buf)
/* Get one language name. */
copy_option_part(&splp, lang, MAXWLEN, ",");
- /* If there is a region name let "region" point to it and remove it
- * from the name. */
region = NULL;
len = STRLEN(lang);
- if (len > 3 && lang[len - 3] == '_')
+
+ /* If the name ends in ".spl" use it as the name of the spell file.
+ * If there is a region name let "region" point to it and remove it
+ * from the name. */
+ if (len > 4 && fnamecmp(lang + len - 4, ".spl") == 0)
{
- region = lang + len - 2;
- len -= 3;
- lang[len] = NUL;
+ filename = TRUE;
+
+ /* Check if we loaded this language before. */
+ for (lp = first_lang; lp != NULL; lp = lp->sl_next)
+ if (fullpathcmp(lang, lp->sl_fname, FALSE) == FPC_SAME)
+ break;
}
+ else
+ {
+ filename = FALSE;
+ if (len > 3 && lang[len - 3] == '_')
+ {
+ region = lang + len - 2;
+ len -= 3;
+ lang[len] = NUL;
+ }
- /* Check if we loaded this language before. */
- for (lp = first_lang; lp != NULL; lp = lp->sl_next)
- if (STRICMP(lp->sl_name, lang) == 0)
- break;
+ /* Check if we loaded this language before. */
+ for (lp = first_lang; lp != NULL; lp = lp->sl_next)
+ if (STRICMP(lang, lp->sl_name) == 0)
+ break;
+ }
/* If not found try loading the language now. */
if (lp == NULL)
- spell_load_lang(lang);
+ {
+ if (filename)
+ (void)spell_load_file(lang, lang, NULL, FALSE);
+ else
+ spell_load_lang(lang);
+ }
/*
* Loop over the languages, there can be several files for "lang".
*/
for (lp = first_lang; lp != NULL; lp = lp->sl_next)
- if (STRICMP(lp->sl_name, lang) == 0)
+ if (filename ? fullpathcmp(lang, lp->sl_fname, FALSE) == FPC_SAME
+ : STRICMP(lang, lp->sl_name) == 0)
{
region_mask = REGION_ALL;
- if (region != NULL)
+ if (!filename && region != NULL)
{
/* find region in sl_regions */
c = find_region(lp->sl_regions, region);
@@ -2311,6 +2333,29 @@ captype(word, end)
return 0;
}
+# if defined(FEAT_MBYTE) || defined(EXITFREE) || defined(PROTO)
+/*
+ * Free all languages.
+ */
+ void
+spell_free_all()
+{
+ slang_T *lp;
+ buf_T *buf;
+
+ /* Go through all buffers and handle 'spelllang'. */
+ for (buf = firstbuf; buf != NULL; buf = buf->b_next)
+ ga_clear(&buf->b_langp);
+
+ while (first_lang != NULL)
+ {
+ lp = first_lang;
+ first_lang = lp->sl_next;
+ slang_free(lp);
+ }
+}
+# endif
+
# if defined(FEAT_MBYTE) || defined(PROTO)
/*
* Clear all spelling tables and reload them.
@@ -2320,25 +2365,17 @@ captype(word, end)
spell_reload()
{
buf_T *buf;
- slang_T *lp;
win_T *wp;
/* Initialize the table for SPELL_ISWORDP(). */
init_spell_chartab();
/* Unload all allocated memory. */
- while (first_lang != NULL)
- {
- lp = first_lang;
- first_lang = lp->sl_next;
- slang_free(lp);
- }
+ spell_free_all();
/* Go through all buffers and handle 'spelllang'. */
for (buf = firstbuf; buf != NULL; buf = buf->b_next)
{
- ga_clear(&buf->b_langp);
-
/* Only load the wordlists when 'spelllang' is set and there is a
* window for this buffer in which 'spell' is set. */
if (*buf->b_p_spl != NUL)
@@ -5290,6 +5327,8 @@ spell_find_suggest(badptr, su, maxcount)
vim_memset(su, 0, sizeof(suginfo_T));
ga_init2(&su->su_ga, (int)sizeof(suggest_T), 10);
ga_init2(&su->su_sga, (int)sizeof(suggest_T), 10);
+ if (*badptr == NUL)
+ return;
hash_init(&su->su_banned);
su->su_badptr = badptr;
@@ -7047,6 +7086,8 @@ add_banned(su, word)
hi = hash_lookup(&su->su_banned, s, hash);
if (HASHITEM_EMPTY(hi))
hash_add_item(&su->su_banned, hi, s, hash);
+ else
+ vim_free(s);
}
}
@@ -7920,10 +7961,15 @@ ex_spelldump(eap)
& lp->lp_region) != 0))
{
word[depth] = NUL;
- dump_word(word, round, flags, lnum++);
+
+ /* Dump the basic word if there is no prefix or
+ * when it's the first one. */
+ c = (unsigned)flags >> 16;
+ if (c == 0 || curi[depth] == 2)
+ dump_word(word, round, flags, lnum++);
/* Apply the prefix, if there is one. */
- if ((unsigned)flags >> 16 != 0)
+ if (c != 0)
lnum = apply_prefixes(slang, word, round,
flags, lnum);
}
diff --git a/src/window.c b/src/window.c
index 0d77a3acfd..cb9e30a355 100644
--- a/src/window.c
+++ b/src/window.c
@@ -26,6 +26,7 @@ static void win_exchange __ARGS((long));
static void win_rotate __ARGS((int, int));
static void win_totop __ARGS((int size, int flags));
static void win_equal_rec __ARGS((win_T *next_curwin, int current, frame_T *topfr, int dir, int col, int row, int width, int height));
+static win_T *win_free_mem __ARGS((win_T *win, int *dirp));
static win_T *winframe_remove __ARGS((win_T *win, int *dirp));
static frame_T *win_altframe __ARGS((win_T *win));
static win_T *frame2win __ARGS((frame_T *frp));
@@ -1808,7 +1809,6 @@ win_close(win, free_buf)
int other_buffer = FALSE;
#endif
int close_curwin = FALSE;
- frame_T *frp;
int dir;
int help_window = FALSE;
@@ -1864,14 +1864,8 @@ win_close(win, free_buf)
if (!win_valid(win) || firstwin == lastwin)
return;
- /* reduce the reference count to the argument list. */
- alist_unlink(win->w_alist);
-
- /* remove the window and its frame from the tree of frames. */
- frp = win->w_frame;
- wp = winframe_remove(win, &dir);
- vim_free(frp);
- win_free(win);
+ /* Free the memory used for the window. */
+ wp = win_free_mem(win, &dir);
/* Make sure curwin isn't invalid. It can cause severe trouble when
* printing an error message. For win_equal() curbuf needs to be valid
@@ -1950,6 +1944,41 @@ win_close(win, free_buf)
}
/*
+ * Free the memory used for a window.
+ * Returns a pointer to the window that got the freed up space.
+ */
+ static win_T *
+win_free_mem(win, dirp)
+ win_T *win;
+ int *dirp; /* set to 'v' or 'h' for direction if 'ea' */
+{
+ frame_T *frp;
+ win_T *wp;
+
+ /* reduce the reference count to the argument list. */
+ alist_unlink(win->w_alist);
+
+ /* remove the window and its frame from the tree of frames. */
+ frp = win->w_frame;
+ wp = winframe_remove(win, dirp);
+ vim_free(frp);
+ win_free(win);
+
+ return wp;
+}
+
+#if defined(EXITFREE) || defined(PROTO)
+ void
+win_free_all()
+{
+ int dummy;
+
+ while (firstwin != NULL)
+ (void)win_free_mem(firstwin, &dummy);
+}
+#endif
+
+/*
* Remove a window and its frame from the tree of frames.
* Returns a pointer to the window that got the freed up space.
*/
@@ -1968,6 +1997,9 @@ winframe_remove(win, dirp)
* Remove the window from its frame.
*/
frp2 = win_altframe(win);
+ if (frp2 == NULL)
+ return NULL; /* deleted the last frame */
+
wp = frame2win(frp2);
/* Remove this frame from the list of frames. */
@@ -2068,7 +2100,7 @@ win_altframe(win)
frp = win->w_frame;
#ifdef FEAT_VERTSPLIT
- if (frp->fr_parent->fr_layout == FR_ROW)
+ if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_ROW)
b = p_spr;
else
#endif