comparison src/misc1.c @ 41:f529edb9bab3 v7.0025

updated for version 7.0025
author vimboss
date Mon, 27 Dec 2004 21:59:20 +0000
parents 410fa1a31baf
children 2201ea50555e
comparison
equal deleted inserted replaced
40:f1d2a58883b9 41:f529edb9bab3
380 } 380 }
381 381
382 /* 382 /*
383 * Return the indent of the current line after a number. Return -1 if no 383 * Return the indent of the current line after a number. Return -1 if no
384 * number was found. Used for 'n' in 'formatoptions': numbered list. 384 * number was found. Used for 'n' in 'formatoptions': numbered list.
385 * Since a pattern is used it can actually handle more than numbers.
385 */ 386 */
386 int 387 int
387 get_number_indent(lnum) 388 get_number_indent(lnum)
388 linenr_T lnum; 389 linenr_T lnum;
389 { 390 {
390 char_u *line;
391 char_u *p;
392 colnr_T col; 391 colnr_T col;
393 pos_T pos; 392 pos_T pos;
393 regmmatch_T regmatch;
394 394
395 if (lnum > curbuf->b_ml.ml_line_count) 395 if (lnum > curbuf->b_ml.ml_line_count)
396 return -1; 396 return -1;
397 line = ml_get(lnum); 397 pos.lnum = 0;
398 p = skipwhite(line); 398 regmatch.regprog = vim_regcomp(curbuf->b_p_flp, RE_MAGIC);
399 if (!VIM_ISDIGIT(*p)) 399 if (regmatch.regprog != NULL)
400 {
401 regmatch.rmm_ic = FALSE;
402 if (vim_regexec_multi(&regmatch, curwin, curbuf, lnum, (colnr_T)0))
403 {
404 pos.lnum = regmatch.endpos[0].lnum + lnum;
405 pos.col = regmatch.endpos[0].col;
406 #ifdef FEAT_VIRTUALEDIT
407 pos.coladd = 0;
408 #endif
409 }
410 vim_free(regmatch.regprog);
411 }
412
413 if (pos.lnum == 0 || *ml_get_pos(&pos) == NUL)
400 return -1; 414 return -1;
401 p = skipdigits(p);
402 if (vim_strchr((char_u *)":.)]}\t ", *p) == NULL)
403 return -1;
404 p = skipwhite(p + 1);
405 if (*p == NUL)
406 return -1;
407 pos.lnum = lnum;
408 pos.col = (colnr_T)(p - line);
409 getvcol(curwin, &pos, &col, NULL, NULL); 415 getvcol(curwin, &pos, &col, NULL, NULL);
410 return (int)col; 416 return (int)col;
411 } 417 }
412 418
413 #if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT) 419 #if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT)
3802 { 3808 {
3803 int len = (int)STRLEN(ext) + 1; 3809 int len = (int)STRLEN(ext) + 1;
3804 char_u *newend = pend - len; 3810 char_u *newend = pend - len;
3805 3811
3806 if (newend >= p && fnamencmp(newend, ext, len - 1) == 0) 3812 if (newend >= p && fnamencmp(newend, ext, len - 1) == 0)
3807 while (newend != p && !after_pathsep(newend)) 3813 while (newend > p && !after_pathsep(p, newend))
3808 mb_ptr_back(newend); 3814 mb_ptr_back(p, newend);
3809 if (newend == p || after_pathsep(newend)) 3815 if (newend == p || after_pathsep(p, newend))
3810 return newend; 3816 return newend;
3811 return pend; 3817 return pend;
3812 } 3818 }
3813 #endif 3819 #endif
3814 3820
8445 #ifndef DONT_ADD_PATHSEP_TO_DIR 8451 #ifndef DONT_ADD_PATHSEP_TO_DIR
8446 if (isdir && (flags & EW_ADDSLASH)) 8452 if (isdir && (flags & EW_ADDSLASH))
8447 add_pathsep(p); 8453 add_pathsep(p);
8448 #endif 8454 #endif
8449 ((char_u **)gap->ga_data)[gap->ga_len++] = p; 8455 ((char_u **)gap->ga_data)[gap->ga_len++] = p;
8450 --gap->ga_room;
8451 } 8456 }
8452 #endif /* !NO_EXPANDPATH */ 8457 #endif /* !NO_EXPANDPATH */
8453 8458
8454 #if defined(VIM_BACKTICK) || defined(FEAT_EVAL) || defined(PROTO) 8459 #if defined(VIM_BACKTICK) || defined(FEAT_EVAL) || defined(PROTO)
8455 8460