summaryrefslogtreecommitdiffstats
path: root/src/charset.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-05-31 22:14:58 +0000
committerBram Moolenaar <Bram@vim.org>2005-05-31 22:14:58 +0000
commit5c06f8b043e413d887ceb1af850ac7ba5034151e (patch)
tree0f7254afd8be58a253c6c73dc9e4711b2ad5bd3e /src/charset.c
parenta04f10b6066952725b53c3bda9ce259ab29a5e3b (diff)
updated for version 7.0077
Diffstat (limited to 'src/charset.c')
-rw-r--r--src/charset.c59
1 files changed, 43 insertions, 16 deletions
diff --git a/src/charset.c b/src/charset.c
index c05a83d26a..25680f677d 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1829,7 +1829,7 @@ skipwhite(p)
}
/*
- * skipdigits: skip over digits;
+ * skip over digits
*/
char_u *
skipdigits(p)
@@ -1840,6 +1840,32 @@ skipdigits(p)
return p;
}
+#if defined(FEAT_EX_EXTRA) || defined(PROTO)
+/*
+ * skip to digit (or NUL after the string)
+ */
+ char_u *
+skiptodigit(p)
+ char_u *p;
+{
+ while (*p != NUL && !VIM_ISDIGIT(*p)) /* skip to next digit */
+ ++p;
+ return p;
+}
+
+/*
+ * skip to hex character (or NUL after the string)
+ */
+ char_u *
+skiptohex(p)
+ char_u *p;
+{
+ while (*p != NUL && !vim_isxdigit(*p)) /* skip to next digit */
+ ++p;
+ return p;
+}
+#endif
+
/*
* Variant of isdigit() that can handle characters > 0x100.
* We don't use isdigit() here, because on some systems it also considers
@@ -1942,6 +1968,10 @@ vim_isblankline(lbuf)
* If "len" is not NULL, the length of the number in characters is returned.
* If "nptr" is not NULL, the signed result is returned in it.
* If "unptr" is not NULL, the unsigned result is returned in it.
+ * If "dooct" is non-zero recognize octal numbers, when > 1 always assume
+ * octal number.
+ * If "dohext" is non-zero recognize hex numbers, when > 1 always assume
+ * hex number.
*/
void
vim_str2nr(start, hexp, len, dooct, dohex, nptr, unptr)
@@ -1995,25 +2025,22 @@ vim_str2nr(start, hexp, len, dooct, dohex, nptr, unptr)
/*
* Do the string-to-numeric conversion "manually" to avoid sscanf quirks.
*/
- if (hex)
+ if (hex == '0' || dooct > 1)
{
- if (hex == '0')
+ /* octal */
+ while ('0' <= *ptr && *ptr <= '7')
{
- /* octal */
- while ('0' <= *ptr && *ptr <= '7')
- {
- un = 8 * un + (unsigned long)(*ptr - '0');
- ++ptr;
- }
+ un = 8 * un + (unsigned long)(*ptr - '0');
+ ++ptr;
}
- else
+ }
+ else if (hex != 0 || dohex > 1)
+ {
+ /* hex */
+ while (vim_isxdigit(*ptr))
{
- /* hex */
- while (vim_isxdigit(*ptr))
- {
- un = 16 * un + (unsigned long)hex2nr(*ptr);
- ++ptr;
- }
+ un = 16 * un + (unsigned long)hex2nr(*ptr);
+ ++ptr;
}
}
else