[hackers] [libutf] add enum Runeself, Runemax || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Thu, 19 Apr 2012 18:43:40 +0200 (CEST)

changeset: 6:1cd7f651b973
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Thu Apr 19 17:41:41 2012 +0100
files: utf.c utf.h
description:
add enum Runeself, Runemax


diff -r 57a29767be6d -r 1cd7f651b973 utf.c
--- a/utf.c Sun Apr 15 16:57:17 2012 +0100
+++ b/utf.c Thu Apr 19 17:41:41 2012 +0100
_AT_@ -125,7 +125,7 @@
                 return 2;
         else if(r <= 0xFFFF)
                 return 3;
- else if(r <= 0x10FFFF)
+ else if(r <= Runemax)
                 return 4;
         else
                 return 0; /* error */
_AT_@ -222,7 +222,7 @@
 char *
 utfrune(const char *s, Rune r)
 {
- if(r <= 0x7F) {
+ if(r < Runeself) {
                 return strchr(s, r);
         }
         else if(r == Runeerror) {
_AT_@ -259,7 +259,7 @@
         Rune r0;
         int n;
 
- if(r <= 0x7F)
+ if(r < Runeself)
                 return strrchr(s, r);
 
         for(; *s != '\0'; s += n) {
diff -r 57a29767be6d -r 1cd7f651b973 utf.h
--- a/utf.h Sun Apr 15 16:57:17 2012 +0100
+++ b/utf.h Thu Apr 19 17:41:41 2012 +0100
_AT_@ -7,8 +7,10 @@
 typedef unsigned int Rune;
 
 enum {
- UTFmax = 6,
- Runeerror = 0xFFFD
+ UTFmax = 6, /* maximum bytes per rune */
+ Runeself = 0x80, /* rune and utf are equal (<) */
+ Runeerror = 0xFFFD, /* decoding error in utf */
+ Runemax = 0x10FFFF /* maximum rune value */
 };
 
 int runetochar(char *, Rune *);
Received on Thu Apr 19 2012 - 18:43:40 CEST

This archive was generated by hypermail 2.3.0 : Thu Apr 19 2012 - 18:48:06 CEST