[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs clang.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs clang.c |
Date: |
Fri, 15 Jul 2016 14:49:03 +0000 (UTC) |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 16/07/15 14:49:03
Modified files:
. : clang.c
Log message:
clang: prevent crash bug if tab-width is set to 0
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.106&r2=1.107
Patches:
Index: clang.c
===================================================================
RCS file: /sources/qemacs/qemacs/clang.c,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -b -r1.106 -r1.107
--- clang.c 21 May 2016 16:04:16 -0000 1.106
+++ clang.c 15 Jul 2016 14:49:03 -0000 1.107
@@ -647,14 +647,15 @@
static int find_indent1(EditState *s, unsigned int *buf)
{
unsigned int *p;
- int pos, c;
+ int pos, c, tw;
+ tw = s->b->tab_width > 0 ? s->b->tab_width : 8;
p = buf;
pos = 0;
for (;;) {
c = *p++ & CHAR_MASK;
if (c == '\t')
- pos += s->b->tab_width - (pos % s->b->tab_width);
+ pos += tw - (pos % tw);
else if (c == ' ')
pos++;
else
@@ -665,13 +666,14 @@
static int find_pos(EditState *s, unsigned int *buf, int size)
{
- int pos, c, i;
+ int pos, c, tw, i;
+ tw = s->b->tab_width > 0 ? s->b->tab_width : 8;
pos = 0;
for (i = 0; i < size; i++) {
c = buf[i] & CHAR_MASK;
if (c == '\t') {
- pos += s->b->tab_width - (pos % s->b->tab_width);
+ pos += tw - (pos % tw);
} else {
/* simplistic case: assume single width characters */
pos++;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs clang.c,
Charlie Gordon <=