Created
December 2, 2011 07:29
-
-
Save lichray/1422199 to your computer and use it in GitHub Desktop.
The NetBSD way to fix v_increment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: src/dist/nvi/vi/v_increment.c | |
diff -u src/dist/nvi/vi/v_increment.c:1.3 src/dist/nvi/vi/v_increment.c:1.4 | |
--- src/dist/nvi/vi/v_increment.c:1.3 Sun Jan 18 03:45:50 2009 | |
+++ src/dist/nvi/vi/v_increment.c Tue Aug 11 21:28:02 2009 | |
@@ -1,4 +1,4 @@ | |
-/* $NetBSD: v_increment.c,v 1.3 2009/01/18 03:45:50 lukem Exp $ */ | |
+/* $NetBSD: v_increment.c,v 1.4 2009/08/11 21:28:02 aymeric Exp $ */ | |
/*- | |
* Copyright (c) 1992, 1993, 1994 | |
@@ -30,17 +30,17 @@ | |
#include "../common/common.h" | |
#include "vi.h" | |
-static const char * const fmt[] = { | |
+static const CHAR_T * const fmt[] = { | |
#define DEC 0 | |
- "%ld", | |
+ L("%ld"), | |
#define SDEC 1 | |
- "%+ld", | |
+ L("%+ld"), | |
#define HEXC 2 | |
- "0X%0*lX", | |
+ L("0X%0*lX"), | |
#define HEXL 3 | |
- "0x%0*lx", | |
+ L("0x%0*lx"), | |
#define OCTAL 4 | |
- "%#0*lo", | |
+ L("%#0*lo"), | |
}; | |
static void inc_err __P((SCR *, enum nresult)); | |
@@ -59,8 +59,8 @@ | |
long ltmp, lval; | |
size_t beg, blen, end, len, nlen, wlen; | |
int base, isempty, rval; | |
- const char *ntype; | |
- char nbuf[100]; | |
+ const CHAR_T *ntype; | |
+ CHAR_T nbuf[100]; | |
CHAR_T *bp, *p, *t; | |
/* Validate the operator. */ | |
@@ -102,7 +102,7 @@ | |
} | |
#undef ishex | |
-#define ishex(c) (isdigit(c) || strchr("abcdefABCDEF", c)) | |
+#define ishex(c) (isdigit(c) || STRCHR(L("abcdefABCDEF"), c)) | |
#undef isoctal | |
#define isoctal(c) (isdigit(c) && (c) != '8' && (c) != '9') | |
@@ -206,7 +206,7 @@ | |
/* If we cross 0, signed numbers lose their sign. */ | |
if (lval == 0 && ntype == fmt[SDEC]) | |
ntype = fmt[DEC]; | |
- nlen = snprintf(nbuf, sizeof(nbuf), ntype, lval); | |
+ nlen = SPRINTF(nbuf, sizeof(nbuf), ntype, lval); | |
} else { | |
if ((nret = nget_uslong(sp, &ulval, t, NULL, base)) != NUM_OK) | |
goto err; | |
@@ -228,7 +228,7 @@ | |
if (base == 16) | |
wlen -= 2; | |
- nlen = snprintf(nbuf, sizeof(nbuf), ntype, wlen, ulval); | |
+ nlen = SPRINTF(nbuf, sizeof(nbuf), ntype, wlen, ulval); | |
} | |
/* Build the new line. */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment