mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-20 16:22:38 -05:00
Clean up splint warnings:
- Inconsistencies between defines.h and estruct.h. - Review scope of termio local variables. - Type mismatch in utf8.
This commit is contained in:
parent
e2be62323b
commit
4b2c50f6d2
5
Makefile
5
Makefile
@ -43,7 +43,7 @@ ifeq ($(uname_S),Darwin)
|
|||||||
DEFINES=-DAUTOCONF -DPOSIX -DSYSV -D_DARWIN_C_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE=600
|
DEFINES=-DAUTOCONF -DPOSIX -DSYSV -D_DARWIN_C_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE=600
|
||||||
endif
|
endif
|
||||||
ifeq ($(uname_S),CYGWIN)
|
ifeq ($(uname_S),CYGWIN)
|
||||||
DEFINES=-DAUTOCONF -DCYGWIN -DPROGRAM=$(PROGRAM)
|
DEFINES=-DAUTOCONF -DCYGWIN -DSYSV -DPROGRAM=$(PROGRAM)
|
||||||
LIBS=-lcurses
|
LIBS=-lcurses
|
||||||
endif
|
endif
|
||||||
ifeq ($(uname_S),MINGW32)
|
ifeq ($(uname_S),MINGW32)
|
||||||
@ -86,6 +86,9 @@ lint: ${SRC}
|
|||||||
lint ${LFLAGS} ${SRC} >lintout
|
lint ${LFLAGS} ${SRC} >lintout
|
||||||
cat lintout
|
cat lintout
|
||||||
|
|
||||||
|
splint:
|
||||||
|
splint $(DEFINES) $(SRC) -booltype boolean -booltrue TRUE -boolfalse FALSE +posixlib
|
||||||
|
|
||||||
errs:
|
errs:
|
||||||
@rm -f makeout
|
@rm -f makeout
|
||||||
make $(PROGRAM) >makeout
|
make $(PROGRAM) >makeout
|
||||||
|
10
defines.h
10
defines.h
@ -1,3 +1,9 @@
|
|||||||
|
/* defines.h -- */
|
||||||
|
|
||||||
|
#ifndef __DEFINES_H__
|
||||||
|
#define __DEFINES_H__
|
||||||
|
|
||||||
|
|
||||||
/* Must define one of
|
/* Must define one of
|
||||||
VMS | V7 | USG | BSD | MSDOS
|
VMS | V7 | USG | BSD | MSDOS
|
||||||
*/
|
*/
|
||||||
@ -18,3 +24,7 @@
|
|||||||
if smaller font or portrait orientation limit to 400x150 */
|
if smaller font or portrait orientation limit to 400x150 */
|
||||||
#define MAXCOL 400
|
#define MAXCOL 400
|
||||||
#define MAXROW 150
|
#define MAXROW 150
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* end of defines.h */
|
||||||
|
13
termio.c
13
termio.c
@ -20,7 +20,6 @@
|
|||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
|
|
||||||
|
|
||||||
/* rfi */
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
@ -58,12 +57,12 @@ int nxtchar = -1; /* character held from type ahead */
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <termio.h>
|
#include <termio.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
int kbdflgs; /* saved keyboard fd flags */
|
static int kbdflgs ; /* saved keyboard fd flags */
|
||||||
int kbdpoll; /* in O_NDELAY mode */
|
static int kbdpoll ; /* in O_NDELAY mode */
|
||||||
int kbdqp; /* there is a char in kbdq */
|
static int kbdqp ; /* there is a char in kbdq */
|
||||||
char kbdq; /* char we've already read */
|
static char kbdq ; /* char we've already read */
|
||||||
struct termio otermio; /* original terminal characteristics */
|
static struct termio otermio ; /* original terminal characteristics */
|
||||||
struct termio ntermio; /* charactoristics to use inside */
|
static struct termio ntermio ; /* characteristics to use inside */
|
||||||
#if XONXOFF
|
#if XONXOFF
|
||||||
#define XXMASK 0016000
|
#define XXMASK 0016000
|
||||||
#endif
|
#endif
|
||||||
|
42
utf8.c
42
utf8.c
@ -1,3 +1,5 @@
|
|||||||
|
/* utf8.c -- implements utf8.h, converts between unicode and UTF-8 */
|
||||||
|
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -18,8 +20,8 @@
|
|||||||
unsigned utf8_to_unicode(char *line, unsigned index, unsigned len, unicode_t *res)
|
unsigned utf8_to_unicode(char *line, unsigned index, unsigned len, unicode_t *res)
|
||||||
{
|
{
|
||||||
unicode_t value ;
|
unicode_t value ;
|
||||||
unsigned char c = line[index];
|
unsigned c = line[ index] & 0xFFU ;
|
||||||
unsigned bytes, mask, i;
|
unsigned bytes, mask, i;
|
||||||
|
|
||||||
*res = c;
|
*res = c;
|
||||||
|
|
||||||
@ -36,12 +38,12 @@ unsigned utf8_to_unicode(char *line, unsigned index, unsigned len, unicode_t *re
|
|||||||
/* Ok, it's 11xxxxxx, do a stupid decode */
|
/* Ok, it's 11xxxxxx, do a stupid decode */
|
||||||
mask = 0x20;
|
mask = 0x20;
|
||||||
bytes = 2;
|
bytes = 2;
|
||||||
while (c & mask) {
|
while( (c & mask) != 0) {
|
||||||
bytes++;
|
bytes++;
|
||||||
mask >>= 1;
|
mask >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bytes is in range [2..4] */
|
/* bytes is in range [2..4] as c was in range [C2..F4] */
|
||||||
len -= index;
|
len -= index;
|
||||||
if (bytes > len)
|
if (bytes > len)
|
||||||
return 1;
|
return 1;
|
||||||
@ -51,7 +53,7 @@ unsigned utf8_to_unicode(char *line, unsigned index, unsigned len, unicode_t *re
|
|||||||
/* Ok, do the bytes */
|
/* Ok, do the bytes */
|
||||||
line += index;
|
line += index;
|
||||||
for (i = 1; i < bytes; i++) {
|
for (i = 1; i < bytes; i++) {
|
||||||
c = line[i];
|
c = line[i] & 0xFFU ;
|
||||||
if ((c & 0xc0) != 0x80)
|
if ((c & 0xc0) != 0x80)
|
||||||
return 1;
|
return 1;
|
||||||
value = (value << 6) | (c & 0x3f);
|
value = (value << 6) | (c & 0x3f);
|
||||||
@ -85,7 +87,7 @@ static void reverse_string(char *begin, char *end)
|
|||||||
* overlong utf-8 sequences.
|
* overlong utf-8 sequences.
|
||||||
*/
|
*/
|
||||||
unsigned unicode_to_utf8( unicode_t c, char *utf8) {
|
unsigned unicode_to_utf8( unicode_t c, char *utf8) {
|
||||||
int bytes = 1 ;
|
unsigned bytes = 1 ;
|
||||||
|
|
||||||
assert( c <= 0x10FFFF) ;
|
assert( c <= 0x10FFFF) ;
|
||||||
|
|
||||||
@ -94,18 +96,24 @@ unsigned unicode_to_utf8( unicode_t c, char *utf8) {
|
|||||||
c &= 0xFF ;
|
c &= 0xFF ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*utf8 = c ;
|
if( c <= 0x7f)
|
||||||
if (c > 0x7f) {
|
*utf8 = (char) c ;
|
||||||
int prefix = 0x40;
|
else {
|
||||||
char *p = utf8;
|
unsigned prefix = 0x40 ;
|
||||||
|
char *p = utf8 ;
|
||||||
do {
|
do {
|
||||||
*p++ = 0x80 + (c & 0x3f);
|
*p++ = (char) (0x80 + (c & 0x3f)) ;
|
||||||
bytes++;
|
bytes++ ;
|
||||||
prefix >>= 1;
|
prefix >>= 1 ;
|
||||||
c >>= 6;
|
c >>= 6 ;
|
||||||
} while( c >= prefix) ;
|
} while( c >= prefix) ;
|
||||||
*p = c - 2*prefix;
|
|
||||||
reverse_string(utf8, p);
|
*p = (char) (c - 2 * prefix) ;
|
||||||
|
reverse_string( utf8, p) ;
|
||||||
}
|
}
|
||||||
return bytes;
|
|
||||||
|
return bytes ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* end of utf8.c */
|
||||||
|
Loading…
Reference in New Issue
Block a user