]> git.mdlowis.com Git - archive/carl.git/commitdiff
Added prototypes for generated runetype functions and stubs for some non-generated...
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 22 Sep 2015 02:26:14 +0000 (22:26 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 22 Sep 2015 02:26:14 +0000 (22:26 -0400)
source/libc.h
source/utf/runetype.c
tests/main.c
tools/unicode.rb

index adf55d4bd6b960ce8833ad5cea3eb16dd0295e00..6fc20cd1f1cc1d696760079c83e49e694248e758 100644 (file)
     (type*)((uintptr_t)obj - offsetof(type, member))
 #endif
 
+#define concat(a,b)  a##b
+
+#define ident(a) concat(id, a)
+
+#define unique_id ident(__LINE__)
+
 /*
  * Assertions
  */
 #include <assert.h>
 
 #ifndef static_assert
-    #ifdef NDEBUG
-        #define static_assert(expr) ((void)0)
-    #else
-        #define static_assert(expr) switch(0){case 0:case (expr):;}
-    #endif
+    #define static_assert(expr) typedef char unique_id[( expr )?1:-1]
 #endif
 
 /*
@@ -179,13 +181,14 @@ void refreplace(void** var, void* val);
 /*
  * Rune Definitions and Routines
  */
-#define UTF_MAX   4        /*< Maximum number of bytes per rune */
-#define Runesync  0x80     /*< Upper bound of a UTF sequence */
-#define Runeself  0x80     /*< Upper bound of a rune sequence */
-#define Runeerror 0xFFFD   /*< Decoding error */
-#define Runemax   0x10FFFF /*< Maximum rune value */
-#define Runemask  0x1FFFFF /*< All bits used by a rune */
-
+#define UTF_MAX   6        /* Maximum number of bytes per rune */
+#define Runesync  0x80     /* Upper bound of a UTF sequence */
+#define Runeself  0x80     /* Upper bound of a rune sequence */
+#define Runeerror 0xFFFD   /* Decoding error */
+#define Runemax   0x10FFFF /* Maximum rune value */
+#define Runemask  0x1FFFFF /* All bits used by a rune */
+
+/* Type representing unicode character types */
 typedef uint32_t Rune;
 
 /**
@@ -347,93 +350,59 @@ Rune* runestrstr(Rune* str1, Rune* str2);
 
 /* Single Source
  *****************************************************************************/
-/** Convert the rune ch to lowercase. */
-Rune tolowerrune(Rune ch);
-
-/** Convert the rune ch to a title rune. */
-Rune totitlerune(Rune ch);
-
-/** Convert the rune ch to uppercase. */
-Rune toupperrune(Rune ch);
-
-/** Convert the rune ch to a base rune. */
-Rune tobaserune(Rune ch);
-
-/** Returns whether the rune is a letter. */
+/** Returns whether the rune is a letter rune. */
 bool isalpharune(Rune ch);
 
-/** Returns whether the rune is a base rune. */
-bool isbaserune(Rune ch);
+/** Returns whether the rune is a control rune. */
+bool iscontrolrune(Rune ch);
 
-/** Returns whether the rune is a digit. */
+/** Returns whether the rune is a digit rune. */
 bool isdigitrune(Rune ch);
 
 /** Returns whether the rune is a lowercase rune. */
 bool islowerrune(Rune ch);
 
+/** Returns whether the rune is a mark rune. */
+bool ismarkrune(Rune ch);
+
+/** Returns whether the rune is a number rune. */
+bool isnumberrune(Rune ch);
+
+/** Returns whether the rune is a other rune. */
+bool isotherrune(Rune ch);
+
+/** Returns whether the rune is a other letter rune. */
+bool isotherletterrune(Rune ch);
+
+/** Returns whether the rune is a punctuation rune. */
+bool ispunctuationrune(Rune ch);
+
 /** Returns whether the rune is a whitespace rune. */
 bool isspacerune(Rune ch);
 
+/** Returns whether the rune is a symbol rune. */
+bool issymbolrune(Rune ch);
+
 /** Returns whether the rune is a title rune. */
 bool istitlerune(Rune ch);
 
 /** Returns whether the rune is a uppercase rune. */
 bool isupperrune(Rune ch);
 
+/** Convert the rune ch to lowercase. */
+Rune tolowerrune(Rune ch);
+
+/** Convert the rune ch to uppercase. */
+Rune toupperrune(Rune ch);
+
+/** Convert the rune ch to a title rune. */
+Rune totitlerune(Rune ch);
+
 /*
  * I/O Routines
  */
 #include <stdio.h>
 
-#if 0
-#define Bsize      8*1024
-#define Bungetsize 4        /* space for ungetc */
-#define Bmagic     0x314159
-#define Beof       -1
-#define Bbad       -2
-
-typedef struct iobuf {
-    int icount;     /* neg num of bytes at eob */
-    int ocount;     /* num of bytes at bob */
-    int rdline;     /* num of bytes after rdline */
-    int runesize;   /* num of bytes of last getrune */
-    int state;      /* r/w/inactive */
-    int fid;        /* open file */
-    int flag;       /* magic if malloc'ed */
-    long long   offset;     /* offset of buffer in file */
-    int bsize;      /* size of buffer */
-    unsigned char*  bbuf;       /* pointer to beginning of buffer */
-    unsigned char*  ebuf;       /* pointer to end of buffer */
-    unsigned char*  gbuf;       /* pointer to good data in buf */
-    unsigned char   b[Bungetsize+Bsize];
-} iobuf;
-
-int iobuffered(iobuf*);
-iobuf* iofdopen(int, int);
-int iofildes(iobuf*);
-int ioflush(iobuf*);
-int iogetc(iobuf*);
-int iogetd(iobuf*, double*);
-long iogetrune(iobuf*);
-int ioinit(iobuf*, int, int);
-int ioinits(iobuf*, int, int, unsigned char*, int);
-int iolinelen(iobuf*);
-long long iooffset(iobuf*);
-iobuf* ioopen(char*, int);
-int ioprint(iobuf*, char*, ...);
-int ioputc(iobuf*, int);
-int ioputrune(iobuf*, long);
-void* iordline(iobuf*, int);
-char* iordstr(iobuf*, int, int);
-long ioread(iobuf*, void*, long);
-long long seek(iobuf*, long long, int);
-int ioterm(iobuf*);
-int ioungetc(iobuf*);
-int ioungetrune(iobuf*);
-long iowrite(iobuf*, void*, long);
-int iovprint(iobuf*, char*, va_list);
-#endif
-
 /*
  * Threads and Atomics
  */
index 9d7ef6b4636a665509f62dfad739697f6de95b85..56dd4ee8832f4df605c142a181f182addde7722e 100644 (file)
@@ -1,20 +1,32 @@
 #include "libc.h"
 
-Rune tolowerrune(Rune ch)
+bool isalnumrune(Rune ch)
 {
-    (void)ch;
-    return 0;
+    return false;
 }
 
-Rune totitlerune(Rune ch)
+bool isblankrune(Rune ch)
 {
-    (void)ch;
-    return 0;
+    return false;
 }
 
-Rune toupperrune(Rune ch)
+bool isgraphrune(Rune ch)
 {
-    (void)ch;
-    return 0;
+    return false;
+}
+
+bool isprintrune(Rune ch)
+{
+    return false;
+}
+
+bool isxdigitrune(Rune ch)
+{
+    return false;
+}
+
+bool iscombiningrune(Rune ch)
+{
+    return false;
 }
 
index a6ef5433beffbd29eedf128b19466da682b1a6d2..13a9fb000c24f10d77a18033f4bcbb62391acdc6 100644 (file)
@@ -1,12 +1,12 @@
 #include "atf.h"
 #include "libc.h"
 
-void main(int argc, char** argv)
+int main(int argc, char** argv)
 {
     (void)argc;
     (void)argv;
     RUN_EXTERN_TEST_SUITE(RefCount);
     RUN_EXTERN_TEST_SUITE(SList);
     RUN_EXTERN_TEST_SUITE(BSTree);
-    exit(PRINT_TEST_RESULTS());
+    return (PRINT_TEST_RESULTS());
 }
index 510333f54ed10ca81a90957137874ade53fdc7b9..5aea81c2f55ec4883565cbbfd8f7313ca34d68e4 100755 (executable)
@@ -163,9 +163,6 @@ unicode_data.each_line do |data|
   else
     register_codepoint(types, char)
   end
-  #register_codepoint([:tolower], char) if char.to_lower != 0
-  #register_codepoint([:toupper], char) if char.to_upper != 0
-  #register_codepoint([:totitle], char) if char.to_title != 0
 end
 unicode_data.close()