=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/vim/Attic/misccmds.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** src/usr.bin/vim/Attic/misccmds.c 1996/09/07 21:40:25 1.1 --- src/usr.bin/vim/Attic/misccmds.c 1996/09/21 06:23:10 1.2 *************** *** 1,4 **** ! /* $OpenBSD: misccmds.c,v 1.1 1996/09/07 21:40:25 downsj Exp $ */ /* vi:set ts=4 sw=4: * * VIM - Vi IMproved by Bram Moolenaar --- 1,4 ---- ! /* $OpenBSD: misccmds.c,v 1.2 1996/09/21 06:23:10 downsj Exp $ */ /* vi:set ts=4 sw=4: * * VIM - Vi IMproved by Bram Moolenaar *************** *** 1390,1396 **** { if (!curbuf->b_changed) { ! change_warning(); curbuf->b_changed = TRUE; check_status(curbuf); } --- 1390,1396 ---- { if (!curbuf->b_changed) { ! change_warning(0); curbuf->b_changed = TRUE; check_status(curbuf); } *************** *** 1441,1447 **** * will be TRUE. */ void ! change_warning() { if (curbuf->b_did_warn == FALSE && curbuf->b_changed == 0 && #ifdef AUTOCMD --- 1441,1449 ---- * will be TRUE. */ void ! change_warning(col) ! int col; /* column for message; non-zero when in insert ! mode and 'showmode' is on */ { if (curbuf->b_did_warn == FALSE && curbuf->b_changed == 0 && #ifdef AUTOCMD *************** *** 1449,1457 **** #endif curbuf->b_p_ro) { ! curbuf->b_did_warn = TRUE; ! MSG("Warning: Changing a readonly file"); mch_delay(1000L, TRUE); /* give him some time to think about it */ } } --- 1451,1466 ---- #endif curbuf->b_p_ro) { ! /* ! * Do what msg() does, but with a column offset. ! */ ! msg_start(); ! msg_col = col; ! MSG_OUTSTR("Warning: Changing a readonly file"); ! msg_clr_eos(); ! (void)msg_end(); mch_delay(1000L, TRUE); /* give him some time to think about it */ + curbuf->b_did_warn = TRUE; } } *************** *** 1800,1807 **** } /* ! * Replace home directory by "~/" in each space or comma separated filename in ! * 'src'. If anything fails (except when out of space) dst equals src. */ void home_replace(buf, src, dst, dstlen) --- 1809,1816 ---- } /* ! * Replace home directory by "~" in each space or comma separated filename in ! * 'src'. If anything fails (except when out of space) dst equals src. */ void home_replace(buf, src, dst, dstlen) *************** *** 1862,1869 **** src += len; if (--dstlen > 0) *dst++ = '~'; /* ! * If it's just the home directory, make it "~/". */ if (!ispathsep(src[0]) && --dstlen > 0) *dst++ = '/'; --- 1871,1879 ---- src += len; if (--dstlen > 0) *dst++ = '~'; + /* ! * If it's just the home directory, add "/". */ if (!ispathsep(src[0]) && --dstlen > 0) *dst++ = '/'; *************** *** 1898,1907 **** char_u *dst; unsigned len; ! if (src == NULL) /* just in case */ ! len = 3; ! else ! len = STRLEN(src) + 3; /* extra space for "~/" and trailing NUL */ dst = alloc(len); if (dst != NULL) home_replace(buf, src, dst, len); --- 1908,1916 ---- char_u *dst; unsigned len; ! len = 3; /* space for "~/" and trailing NUL */ ! if (src != NULL) /* just in case */ ! len += STRLEN(src); dst = alloc(len); if (dst != NULL) home_replace(buf, src, dst, len); *************** *** 1984,1989 **** --- 1993,2032 ---- } /* + * Get a pointer to one character past the head of a path name. + * Unix: after "/"; DOS: after "c:\"; Amiga: after "disk:/". + * If there is no head, path is returned. + */ + char_u * + get_past_head(path) + char_u *path; + { + char_u *retval; + + #if defined(MSDOS) || defined(WIN32) || defined(OS2) + /* may skip "c:" */ + if (isalpha(path[0]) && path[1] == ':') + retval = path + 2; + else + retval = path; + #else + # if defined(AMIGA) + /* may skip "label:" */ + retval = vim_strchr(path, ':'); + if (retval == NULL) + retval = path; + # else /* Unix */ + retval = path; + # endif + #endif + + while (ispathsep(*retval)) + ++retval; + + return retval; + } + + /* * return TRUE if 'c' is a path separator. */ int *************** *** 2307,2312 **** --- 2350,2356 ---- /* * Recognize a line that starts with '{' or '}', or ends with ';' or '}'. + * Don't consider "} else" a terminated line. * Also consider a line terminated if it ends in ','. This is not 100% * correct, but this mostly means we are in initializations and then it's OK. */ *************** *** 2316,2322 **** { s = skipwhite(s); ! if (*s == '{' || *s == '}') return TRUE; while (*s) --- 2360,2366 ---- { s = skipwhite(s); ! if (*s == '{' || (*s == '}' && !iselse(s))) return TRUE; while (*s) *************** *** 2416,2421 **** --- 2460,2467 ---- iselse(p) char_u *p; { + if (*p == '}') /* accept "} else" */ + p = skipwhite(p + 1); return (STRNCMP(p, "else", 4) == 0 && !isidchar(p[4])); } *************** *** 2442,2452 **** --- 2488,2506 ---- int retval = FALSE; p = skipwhite(p); + if (*p == '}') /* accept "} while (cond);" */ + p = skipwhite(p + 1); if (STRNCMP(p, "while", 5) == 0 && !isidchar(p[5])) { cursor_save = curwin->w_cursor; curwin->w_cursor.lnum = lnum; curwin->w_cursor.col = 0; + p = ml_get_curline(); + while (*p && *p != 'w') /* skip any '}', until the 'w' of the "while" */ + { + ++p; + ++curwin->w_cursor.col; + } if ((trypos = findmatchlimit(0, 0, ind_maxparen)) != NULL) { p = ml_get_pos(trypos) + 1; *************** *** 3254,3261 **** /* * Check if we are after an "if", "while", etc. */ ! if (is_cinword(l)) { /* * Found an unterminated line after an if (), line up --- 3308,3316 ---- /* * Check if we are after an "if", "while", etc. + * Also allow "} else". */ ! if (is_cinword(l) || iselse(l)) { /* * Found an unterminated line after an if (), line up *************** *** 3349,3355 **** /* * Check if we are after a while (cond); ! * If so: Ignore the matching "do". */ /* XXX */ else if (iswhileofdo(l, curwin->w_cursor.lnum, ind_maxparen)) --- 3404,3410 ---- /* * Check if we are after a while (cond); ! * If so: Ignore until the matching "do". */ /* XXX */ else if (iswhileofdo(l, curwin->w_cursor.lnum, ind_maxparen))