[hackers] [libutf] clean up mkrunetype & utftest || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Mon, 7 May 2012 15:10:11 +0200 (CEST)

changeset: 8:392f6d360c43
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Mon May 07 14:09:30 2012 +0100
files: mkrunetype.awk utftest.c
description:
clean up mkrunetype & utftest


diff -r d3d4ccaaa904 -r 392f6d360c43 mkrunetype.awk
--- a/mkrunetype.awk Sun May 06 20:36:37 2012 +0100
+++ b/mkrunetype.awk Mon May 07 14:09:30 2012 +0100
_AT_@ -2,7 +2,7 @@
 
 BEGIN {
         FS = ";"
- # setup hexadecimal lookup table
+ # set up hexadecimal lookup table
         for(i = 0; i < 16; i++)
                 hex[sprintf("%X",i)] = i;
 }
_AT_@ -25,6 +25,7 @@
         mkis("digit", digitv, digitc);
 }
 
+# parse hexadecimal rune index to int
 function code(s) {
         x = 0;
         for(i = 1; i <= length(s); i++) {
_AT_@ -34,10 +35,12 @@
         return x;
 }
 
+# generate 'is<name>rune' unicode lookup function
 function mkis(name, runev, runec) {
         rune1c = 0;
         rune2c = 0;
 
+ # sort rune groups into singletons and ranges
         for(j = k = 0; j < runec; j++) {
                 if(j+1 == runec || code(runev[j+1]) != code(runev[j])+1) {
                         if(j == k) {
_AT_@ -52,6 +55,7 @@
                         k = j+1;
                 }
         }
+ # generate list of ranges
         if(rune2c > 0) {
                 print "static Rune "name"2[][2] = {";
                 for(j = 0; j < rune2c; j++) {
_AT_@ -59,6 +63,7 @@
                 }
                 print "};\n";
         }
+ # generate list of singletons
         if(rune1c > 0) {
                 print "static Rune "name"1[] = {";
                 for(j = 0; j < rune1c; j++) {
_AT_@ -66,6 +71,7 @@
                 }
                 print "};\n";
         }
+ # generate lookup function
         print "int\nis"name"rune(Rune r)\n{";
         if(rune2c > 0)
                 print "\tif(bsearch(&r, "name"2, nelem("name"2), sizeof *"name"2, &rune2cmp))\n\t\treturn 1;";
diff -r d3d4ccaaa904 -r 392f6d360c43 utftest.c
--- a/utftest.c Sun May 06 20:36:37 2012 +0100
+++ b/utftest.c Mon May 07 14:09:30 2012 +0100
_AT_@ -5,23 +5,25 @@
 #include <string.h>
 #include "utf.h"
 
-#define ARGBEGIN \
- { \
- Rune _argr; \
- \
- if(!argv0) \
- argv0 = argv[0]; \
+#define ARGBEGIN \
+ { \
+ Rune _argr; \
+ \
+ if(!argv0) \
+ argv0 = argv[0]; \
                 for(argc--, argv++; *argv && (*argv)[0] == '-' && (*argv)[1] != '\0'; argc--, argv++) { \
- if((*argv)[1] == '-' && (*argv)[2] == '\0') { /* -- signifies end of flags */ \
- argc--; argv++; \
- break; \
- } \
- (*argv)++; \
- while(**argv != '\0' && (*argv += chartorune(&_argr, *argv))) \
+ if((*argv)[1] == '-' && (*argv)[2] == '\0') { /* -- signifies end of flags */ \
+ argc--; argv++; \
+ break; \
+ } \
+ (*argv)++; \
+ while(**argv != '\0' && (*argv += chartorune(&_argr, *argv))) \
                                 switch(_argr)
-#define ARGEND \
- } \
+
+#define ARGEND \
+ } \
         }
+
 #define ARGC() _argr
 
 static void eprintf(const char *, ...);
_AT_@ -107,6 +109,6 @@
 void
 usage(void)
 {
- fprintf(stderr, "usage: %s [-adlstu]\n", argv0);
+ fprintf(stderr, "usage: %s [-adlstuv]\n", argv0);
         exit(EXIT_FAILURE);
 }
Received on Mon May 07 2012 - 15:10:11 CEST

This archive was generated by hypermail 2.3.0 : Mon May 07 2012 - 15:12:06 CEST