]> granicus.if.org Git - vim/commitdiff
updated for version 7.0092
authorBram Moolenaar <Bram@vim.org>
Fri, 24 Jun 2005 23:01:23 +0000 (23:01 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 24 Jun 2005 23:01:23 +0000 (23:01 +0000)
14 files changed:
runtime/indent/pyrex.vim
runtime/spell/en.ascii.spl
src/Makefile
src/ex_docmd.c
src/fileio.c
src/message.c
src/os_unix.c
src/proto/ex_docmd.pro
src/proto/ex_getln.pro
src/proto/message.pro
src/proto/ops.pro
src/proto/syntax.pro
src/spell.c
src/window.c

index e7771264eaff94591fbc097d7bbd2220b15e5f78..a1a17466721d4fababea3638e64a5bb9af7b9ca3 100644 (file)
@@ -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
index 54630e7a6cd95c18135d9567d2e59480ac005dbf..739899cd1d5d5a0149115e02193e7b8479734e79 100644 (file)
Binary files a/runtime/spell/en.ascii.spl and b/runtime/spell/en.ascii.spl differ
index f27e20d1ea23fc5816f9767579fc46a1f82f34bc..03ee7c28b7486529d5f17b4679e239b572ebad0e 100644 (file)
@@ -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!  ### {{{
 #####################################################
index fa94424f62a1dcdd1c7417106c298083175c5c26..af3e7f9bfe3ad3d7efac1a66349bd58963f8a890 100644 (file)
@@ -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;
 {
index 9ae69cf1069afcc9d487f5dbd3a171185e60a075..dd42fb4cf97b4f8315e4bc74f1208efbd426f128 100644 (file)
@@ -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;
index 535d65a51a9cfe20542ca0da1f96486c0972c774..a43cb9287f1c3ce414f4cb8504d541cec3f21aee 100644 (file)
@@ -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)
@@ -776,6 +771,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.
  */
index ba74a2de139f82b7ef01c204b12fc705ce4bb107..d27b05a6d37617b37269b52b595a8d36879fadb5 100644 (file)
@@ -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);
 }
 
index 9a0fd2b3c3ae27695ccf4e9166dba752ad33dc18..3a8200e38d63b81a2daa167d4359bb5db32c0f12 100644 (file)
@@ -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));
index 97d3c2f7fd72b3cf9ed959b60b594eb98e47dbbf..688eb3d8f0d6c4582d6c90402ca0c630d12bb2a3 100644 (file)
@@ -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));
index f6b29a296fb01f8554d81f27bb27ec563aba613d..d76182d91fc2dfb28eba63fffa227c7532cf38e9 100644 (file)
@@ -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));
index 5952b951e3ab69cbda56118e9959ba7c3235afbc..da9973bbe37f55caee4f9c144dec8539de67cca9 100644 (file)
@@ -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));
index 3a29674bd7703835d48dd944f02829df8caa7eb0..967d88ed3a14d93cf65883dd27a2ae37f0fb20ad 100644 (file)
@@ -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));
index 4ff413a7148bd3b2f2a8698349ede1bd2a74b18a..c5d81229e7d6154d4905b79bcdc58eb8f5cc53b4 100644 (file)
@@ -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);
                        }
index 0d77a3acfd7800a6275db1c2e98e52789ee3f49a..cb9e30a3554883519b91ed73b19b4b1ebafd520a 100644 (file)
@@ -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
@@ -1949,6 +1943,41 @@ win_close(win, free_buf)
     redraw_all_later(NOT_VALID);
 }
 
+/*
+ * 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