Mercurial > vim
comparison src/regexp.c @ 15480:bd12ace1bab2 v8.1.0748
patch 8.1.0748: using sprintf() instead of semsg()
commit https://github.com/vim/vim/commit/1be45b2ea76ae2e39817a98a584d4d6cbb983a7b
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 14 22:46:15 2019 +0100
patch 8.1.0748: using sprintf() instead of semsg()
Problem: Using sprintf() instead of semsg().
Solution: Use semsg(). Fix bug with E888. (Ozaki Kiichi, closes https://github.com/vim/vim/issues/3801)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 14 Jan 2019 23:00:05 +0100 |
parents | 55ccc2d353bd |
children | dd725a8ab112 |
comparison
equal
deleted
inserted
replaced
15479:d38f503510b5 | 15480:bd12ace1bab2 |
---|---|
336 * rc_did_emsg and return NULL */ | 336 * rc_did_emsg and return NULL */ |
337 #define EMSG_RET_NULL(m) return (emsg((m)), rc_did_emsg = TRUE, (void *)NULL) | 337 #define EMSG_RET_NULL(m) return (emsg((m)), rc_did_emsg = TRUE, (void *)NULL) |
338 #define IEMSG_RET_NULL(m) return (iemsg((m)), rc_did_emsg = TRUE, (void *)NULL) | 338 #define IEMSG_RET_NULL(m) return (iemsg((m)), rc_did_emsg = TRUE, (void *)NULL) |
339 #define EMSG_RET_FAIL(m) return (emsg((m)), rc_did_emsg = TRUE, FAIL) | 339 #define EMSG_RET_FAIL(m) return (emsg((m)), rc_did_emsg = TRUE, FAIL) |
340 #define EMSG2_RET_NULL(m, c) return (semsg((const char *)(m), (c) ? "" : "\\"), rc_did_emsg = TRUE, (void *)NULL) | 340 #define EMSG2_RET_NULL(m, c) return (semsg((const char *)(m), (c) ? "" : "\\"), rc_did_emsg = TRUE, (void *)NULL) |
341 #define EMSG3_RET_NULL(m, c, a) return (semsg((const char *)(m), (c) ? "" : "\\", (a)), rc_did_emsg = TRUE, (void *)NULL) | |
341 #define EMSG2_RET_FAIL(m, c) return (semsg((const char *)(m), (c) ? "" : "\\"), rc_did_emsg = TRUE, FAIL) | 342 #define EMSG2_RET_FAIL(m, c) return (semsg((const char *)(m), (c) ? "" : "\\"), rc_did_emsg = TRUE, FAIL) |
342 #define EMSG_ONE_RET_NULL EMSG2_RET_NULL(_("E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL) | 343 #define EMSG_ONE_RET_NULL EMSG2_RET_NULL(_("E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL) |
343 | 344 |
344 | 345 |
345 #define MAX_LIMIT (32767L << 16L) | 346 #define MAX_LIMIT (32767L << 16L) |
1893 *flagp = (HASWIDTH | (flags & (HASNL | HASLOOKBH))); | 1894 *flagp = (HASWIDTH | (flags & (HASNL | HASLOOKBH))); |
1894 break; | 1895 break; |
1895 } | 1896 } |
1896 if (re_multi_type(peekchr()) != NOT_MULTI) | 1897 if (re_multi_type(peekchr()) != NOT_MULTI) |
1897 { | 1898 { |
1898 /* Can't have a multi follow a multi. */ | 1899 // Can't have a multi follow a multi. |
1899 if (peekchr() == Magic('*')) | 1900 if (peekchr() == Magic('*')) |
1900 sprintf((char *)IObuff, _("E61: Nested %s*"), | 1901 EMSG2_RET_NULL(_("E61: Nested %s*"), reg_magic >= MAGIC_ON); |
1901 reg_magic >= MAGIC_ON ? "" : "\\"); | 1902 EMSG3_RET_NULL(_("E62: Nested %s%c"), reg_magic == MAGIC_ALL, |
1902 else | 1903 no_Magic(peekchr())); |
1903 sprintf((char *)IObuff, _("E62: Nested %s%c"), | |
1904 reg_magic == MAGIC_ALL ? "" : "\\", no_Magic(peekchr())); | |
1905 EMSG_RET_NULL((char *)IObuff); | |
1906 } | 1904 } |
1907 | 1905 |
1908 return ret; | 1906 return ret; |
1909 } | 1907 } |
1910 | 1908 |
2073 case Magic('+'): | 2071 case Magic('+'): |
2074 case Magic('@'): | 2072 case Magic('@'): |
2075 case Magic('{'): | 2073 case Magic('{'): |
2076 case Magic('*'): | 2074 case Magic('*'): |
2077 c = no_Magic(c); | 2075 c = no_Magic(c); |
2078 sprintf((char *)IObuff, _("E64: %s%c follows nothing"), | 2076 EMSG3_RET_NULL(_("E64: %s%c follows nothing"), |
2079 (c == '*' ? reg_magic >= MAGIC_ON : reg_magic == MAGIC_ALL) | 2077 (c == '*' ? reg_magic >= MAGIC_ON : reg_magic == MAGIC_ALL), c); |
2080 ? "" : "\\", c); | |
2081 EMSG_RET_NULL((char *)IObuff); | |
2082 /* NOTREACHED */ | 2078 /* NOTREACHED */ |
2083 | 2079 |
2084 case Magic('~'): /* previous substitute pattern */ | 2080 case Magic('~'): /* previous substitute pattern */ |
2085 if (reg_prev_sub != NULL) | 2081 if (reg_prev_sub != NULL) |
2086 { | 2082 { |
3401 else | 3397 else |
3402 *maxval = MAX_LIMIT; /* It was \{} or \{-} */ | 3398 *maxval = MAX_LIMIT; /* It was \{} or \{-} */ |
3403 if (*regparse == '\\') | 3399 if (*regparse == '\\') |
3404 regparse++; /* Allow either \{...} or \{...\} */ | 3400 regparse++; /* Allow either \{...} or \{...\} */ |
3405 if (*regparse != '}') | 3401 if (*regparse != '}') |
3406 { | 3402 EMSG2_RET_FAIL(_("E554: Syntax error in %s{...}"), |
3407 sprintf((char *)IObuff, _("E554: Syntax error in %s{...}"), | 3403 reg_magic == MAGIC_ALL); |
3408 reg_magic == MAGIC_ALL ? "" : "\\"); | |
3409 EMSG_RET_FAIL((char *)IObuff); | |
3410 } | |
3411 | 3404 |
3412 /* | 3405 /* |
3413 * Reverse the range if there was a '-', or make sure it is in the right | 3406 * Reverse the range if there was a '-', or make sure it is in the right |
3414 * order otherwise. | 3407 * order otherwise. |
3415 */ | 3408 */ |
6996 */ | 6989 */ |
6997 static int | 6990 static int |
6998 re_mult_next(char *what) | 6991 re_mult_next(char *what) |
6999 { | 6992 { |
7000 if (re_multi_type(peekchr()) == MULTI_MULT) | 6993 if (re_multi_type(peekchr()) == MULTI_MULT) |
7001 EMSG2_RET_FAIL(_("E888: (NFA regexp) cannot repeat %s"), what); | 6994 { |
6995 semsg(_("E888: (NFA regexp) cannot repeat %s"), what); | |
6996 rc_did_emsg = TRUE; | |
6997 return FAIL; | |
6998 } | |
7002 return OK; | 6999 return OK; |
7003 } | 7000 } |
7004 | 7001 |
7005 #ifdef FEAT_MBYTE | 7002 #ifdef FEAT_MBYTE |
7006 typedef struct | 7003 typedef struct |