diff src/undo.c @ 2311:ccda151dde4e vim73

Support completion for ":find". (Nazri Ramliy) Cleanup white space.
author Bram Moolenaar <bram@vim.org>
date Wed, 14 Jul 2010 16:52:17 +0200
parents 3331756e4232
children f6540762173d
line wrap: on
line diff
--- a/src/undo.c
+++ b/src/undo.c
@@ -766,7 +766,7 @@ u_get_undo_file_name(buf_ffname, reading
     dirp = p_udir;
     while (*dirp != NUL)
     {
-        dir_len = copy_option_part(&dirp, dir_name, IOSIZE, ",");
+	dir_len = copy_option_part(&dirp, dir_name, IOSIZE, ",");
 	if (dir_len == 1 && dir_name[0] == '.')
 	{
 	    /* Use same directory as the ffname,
@@ -1135,9 +1135,9 @@ serialize_uep(fp, buf, uep)
     for (i = 0; i < uep->ue_size; ++i)
     {
 	len = STRLEN(uep->ue_array[i]);
-        if (put_bytes(fp, (long_u)len, 4) == FAIL)
+	if (put_bytes(fp, (long_u)len, 4) == FAIL)
 	    return FAIL;
-        if (len > 0 && fwrite_crypt(buf, uep->ue_array[i], len, fp) != 1)
+	if (len > 0 && fwrite_crypt(buf, uep->ue_array[i], len, fp) != 1)
 	    return FAIL;
     }
     return OK;
@@ -1317,7 +1317,7 @@ u_write_undo(name, forceit, buf, hash)
 
     if (name == NULL)
     {
-        file_name = u_get_undo_file_name(buf->b_ffname, FALSE);
+	file_name = u_get_undo_file_name(buf->b_ffname, FALSE);
 	if (file_name == NULL)
 	{
 	    if (p_verbose > 0)
@@ -1331,7 +1331,7 @@ u_write_undo(name, forceit, buf, hash)
 	}
     }
     else
-        file_name = name;
+	file_name = name;
 
     /*
      * Decide about the permission to use for the undo file.  If the buffer
@@ -1419,7 +1419,7 @@ u_write_undo(name, forceit, buf, hash)
 			    O_CREAT|O_EXTRA|O_WRONLY|O_EXCL|O_NOFOLLOW, perm);
     if (fd < 0)
     {
-        EMSG2(_(e_not_open), file_name);
+	EMSG2(_(e_not_open), file_name);
 	goto theend;
     }
     (void)mch_setperm(file_name, perm);
@@ -1457,7 +1457,7 @@ u_write_undo(name, forceit, buf, hash)
     fp = fdopen(fd, "w");
     if (fp == NULL)
     {
-        EMSG2(_(e_not_open), file_name);
+	EMSG2(_(e_not_open), file_name);
 	close(fd);
 	mch_remove(file_name);
 	goto theend;
@@ -1483,30 +1483,30 @@ u_write_undo(name, forceit, buf, hash)
     uhp = buf->b_u_oldhead;
     while (uhp != NULL)
     {
-        /* Serialize current UHP if we haven't seen it */
-        if (uhp->uh_walk != mark)
-        {
-            uhp->uh_walk = mark;
+	/* Serialize current UHP if we haven't seen it */
+	if (uhp->uh_walk != mark)
+	{
+	    uhp->uh_walk = mark;
 #ifdef U_DEBUG
 	    ++headers_written;
 #endif
 	    if (serialize_uhp(fp, buf, uhp) == FAIL)
 		goto write_error;
-        }
+	}
 
-        /* Now walk through the tree - algorithm from undo_time(). */
-        if (uhp->uh_prev.ptr != NULL && uhp->uh_prev.ptr->uh_walk != mark)
-            uhp = uhp->uh_prev.ptr;
-        else if (uhp->uh_alt_next.ptr != NULL
+	/* Now walk through the tree - algorithm from undo_time(). */
+	if (uhp->uh_prev.ptr != NULL && uhp->uh_prev.ptr->uh_walk != mark)
+	    uhp = uhp->uh_prev.ptr;
+	else if (uhp->uh_alt_next.ptr != NULL
 				     && uhp->uh_alt_next.ptr->uh_walk != mark)
-            uhp = uhp->uh_alt_next.ptr;
-        else if (uhp->uh_next.ptr != NULL && uhp->uh_alt_prev.ptr == NULL
+	    uhp = uhp->uh_alt_next.ptr;
+	else if (uhp->uh_next.ptr != NULL && uhp->uh_alt_prev.ptr == NULL
 					 && uhp->uh_next.ptr->uh_walk != mark)
-            uhp = uhp->uh_next.ptr;
-        else if (uhp->uh_alt_prev.ptr != NULL)
-            uhp = uhp->uh_alt_prev.ptr;
-        else
-            uhp = uhp->uh_next.ptr;
+	    uhp = uhp->uh_next.ptr;
+	else if (uhp->uh_alt_prev.ptr != NULL)
+	    uhp = uhp->uh_alt_prev.ptr;
+	else
+	    uhp = uhp->uh_next.ptr;
     }
 
     if (put_bytes(fp, (long_u)UF_HEADER_END_MAGIC, 2) == OK)
@@ -1520,7 +1520,7 @@ u_write_undo(name, forceit, buf, hash)
 write_error:
     fclose(fp);
     if (!write_ok)
-        EMSG2(_("E829: write error in undo file: %s"), file_name);
+	EMSG2(_("E829: write error in undo file: %s"), file_name);
 
 #if defined(MACOS_CLASSIC) || defined(WIN3264)
     /* Copy file attributes; for systems where this can only be done after
@@ -1595,7 +1595,7 @@ u_read_undo(name, hash, orig_name)
 
     if (name == NULL)
     {
-        file_name = u_get_undo_file_name(curbuf->b_ffname, TRUE);
+	file_name = u_get_undo_file_name(curbuf->b_ffname, TRUE);
 	if (file_name == NULL)
 	    return;
 
@@ -1618,7 +1618,7 @@ u_read_undo(name, hash, orig_name)
 #endif
     }
     else
-        file_name = name;
+	file_name = name;
 
     if (p_verbose > 0)
     {
@@ -1630,8 +1630,8 @@ u_read_undo(name, hash, orig_name)
     fp = mch_fopen((char *)file_name, "r");
     if (fp == NULL)
     {
-        if (name != NULL || p_verbose > 0)
-            EMSG2(_("E822: Cannot open undo file for reading: %s"), file_name);
+	if (name != NULL || p_verbose > 0)
+	    EMSG2(_("E822: Cannot open undo file for reading: %s"), file_name);
 	goto error;
     }
 
@@ -1642,7 +1642,7 @@ u_read_undo(name, hash, orig_name)
 		|| memcmp(magic_buf, UF_START_MAGIC, UF_START_MAGIC_LEN) != 0)
     {
 	EMSG2(_("E823: Not an undo file: %s"), file_name);
-        goto error;
+	goto error;
     }
     version = get2c(fp);
     if (version == UF_VERSION_CRYPT || version == UF_VERSION_CRYPT_PREV)
@@ -1661,42 +1661,42 @@ u_read_undo(name, hash, orig_name)
 	}
 	do_decrypt = TRUE;
 #else
-        EMSG2(_("E827: Undo file is encrypted: %s"), file_name);
-        goto error;
+	EMSG2(_("E827: Undo file is encrypted: %s"), file_name);
+	goto error;
 #endif
     }
     else if (version != UF_VERSION && version != UF_VERSION_PREV)
     {
-        EMSG2(_("E824: Incompatible undo file: %s"), file_name);
-        goto error;
+	EMSG2(_("E824: Incompatible undo file: %s"), file_name);
+	goto error;
     }
     new_version = (version == UF_VERSION || version == UF_VERSION_CRYPT);
 
     if (fread(read_hash, UNDO_HASH_SIZE, 1, fp) != 1)
     {
 	corruption_error("hash", file_name);
-        goto error;
+	goto error;
     }
     line_count = (linenr_T)get4c(fp);
     if (memcmp(hash, read_hash, UNDO_HASH_SIZE) != 0
 				  || line_count != curbuf->b_ml.ml_line_count)
     {
-        if (p_verbose > 0 || name != NULL)
-        {
+	if (p_verbose > 0 || name != NULL)
+	{
 	    if (name == NULL)
 		verbose_enter();
-            give_warning((char_u *)
+	    give_warning((char_u *)
 		      _("File contents changed, cannot use undo info"), TRUE);
 	    if (name == NULL)
 		verbose_leave();
-        }
-        goto error;
+	}
+	goto error;
     }
 
     /* Read undo data for "U" command. */
     str_len = get4c(fp);
     if (str_len < 0)
-        goto error;
+	goto error;
     if (str_len > 0)
 	line_ptr = read_string_decrypt(curbuf, fp, str_len);
     line_lnum = (linenr_T)get4c(fp);
@@ -1788,61 +1788,61 @@ u_read_undo(name, hash, orig_name)
      * a pointer corresponding to the header with that sequence number. */
     for (i = 0; i < num_head; i++)
     {
-        uhp = uhp_table[i];
-        if (uhp == NULL)
-            continue;
-        for (j = 0; j < num_head; j++)
-            if (uhp_table[j] != NULL && i != j
+	uhp = uhp_table[i];
+	if (uhp == NULL)
+	    continue;
+	for (j = 0; j < num_head; j++)
+	    if (uhp_table[j] != NULL && i != j
 			      && uhp_table[i]->uh_seq == uhp_table[j]->uh_seq)
-            {
+	    {
 		corruption_error("duplicate uh_seq", file_name);
-                goto error;
+		goto error;
 	    }
-        for (j = 0; j < num_head; j++)
-            if (uhp_table[j] != NULL
+	for (j = 0; j < num_head; j++)
+	    if (uhp_table[j] != NULL
 				  && uhp_table[j]->uh_seq == uhp->uh_next.seq)
 	    {
-                uhp->uh_next.ptr = uhp_table[j];
+		uhp->uh_next.ptr = uhp_table[j];
 		SET_FLAG(j);
 		break;
 	    }
-        for (j = 0; j < num_head; j++)
-            if (uhp_table[j] != NULL
+	for (j = 0; j < num_head; j++)
+	    if (uhp_table[j] != NULL
 				  && uhp_table[j]->uh_seq == uhp->uh_prev.seq)
 	    {
-                uhp->uh_prev.ptr = uhp_table[j];
+		uhp->uh_prev.ptr = uhp_table[j];
 		SET_FLAG(j);
 		break;
 	    }
-        for (j = 0; j < num_head; j++)
-            if (uhp_table[j] != NULL
+	for (j = 0; j < num_head; j++)
+	    if (uhp_table[j] != NULL
 			      && uhp_table[j]->uh_seq == uhp->uh_alt_next.seq)
 	    {
-                uhp->uh_alt_next.ptr = uhp_table[j];
+		uhp->uh_alt_next.ptr = uhp_table[j];
 		SET_FLAG(j);
 		break;
 	    }
-        for (j = 0; j < num_head; j++)
-            if (uhp_table[j] != NULL
+	for (j = 0; j < num_head; j++)
+	    if (uhp_table[j] != NULL
 			      && uhp_table[j]->uh_seq == uhp->uh_alt_prev.seq)
 	    {
-                uhp->uh_alt_prev.ptr = uhp_table[j];
+		uhp->uh_alt_prev.ptr = uhp_table[j];
 		SET_FLAG(j);
 		break;
 	    }
-        if (old_header_seq > 0 && old_idx < 0 && uhp->uh_seq == old_header_seq)
+	if (old_header_seq > 0 && old_idx < 0 && uhp->uh_seq == old_header_seq)
 	{
-            old_idx = i;
+	    old_idx = i;
 	    SET_FLAG(i);
 	}
-        if (new_header_seq > 0 && new_idx < 0 && uhp->uh_seq == new_header_seq)
+	if (new_header_seq > 0 && new_idx < 0 && uhp->uh_seq == new_header_seq)
 	{
-            new_idx = i;
+	    new_idx = i;
 	    SET_FLAG(i);
 	}
-        if (cur_header_seq > 0 && cur_idx < 0 && uhp->uh_seq == cur_header_seq)
+	if (cur_header_seq > 0 && cur_idx < 0 && uhp->uh_seq == cur_header_seq)
 	{
-            cur_idx = i;
+	    cur_idx = i;
 	    SET_FLAG(i);
 	}
     }
@@ -1881,10 +1881,10 @@ error:
     vim_free(line_ptr);
     if (uhp_table != NULL)
     {
-        for (i = 0; i < num_read_uhps; i++)
-            if (uhp_table[i] != NULL)
+	for (i = 0; i < num_read_uhps; i++)
+	    if (uhp_table[i] != NULL)
 		u_free_uhp(uhp_table[i]);
-        vim_free(uhp_table);
+	vim_free(uhp_table);
     }
 
 theend:
@@ -1893,7 +1893,7 @@ theend:
 	crypt_pop_state();
 #endif
     if (fp != NULL)
-        fclose(fp);
+	fclose(fp);
     if (file_name != name)
 	vim_free(file_name);
     return;