summary refs log tree commit diff
path: root/port
diff options
context:
space:
mode:
Diffstat (limited to 'port')
-rw-r--r--port/ddate/.gitignore1
-rw-r--r--port/ddate/Makefile15
-rw-r--r--port/ddate/ddate.1117
-rw-r--r--port/ddate/ddate.c399
-rw-r--r--port/wcwidth/.gitignore2
-rw-r--r--port/wcwidth/Makefile19
-rw-r--r--port/wcwidth/nonspacing.h89
-rw-r--r--port/wcwidth/wcswidth.c8
-rw-r--r--port/wcwidth/wcwidth.c29
-rw-r--r--port/wcwidth/wide.h65
10 files changed, 532 insertions, 212 deletions
diff --git a/port/ddate/.gitignore b/port/ddate/.gitignore
new file mode 100644
index 00000000..eaa8a5fd
--- /dev/null
+++ b/port/ddate/.gitignore
@@ -0,0 +1 @@
+ddate
diff --git a/port/ddate/Makefile b/port/ddate/Makefile
new file mode 100644
index 00000000..c1bc4553
--- /dev/null
+++ b/port/ddate/Makefile
@@ -0,0 +1,15 @@
+PREFIX ?= ~/.local
+MANDIR ?= ${PREFIX}/share/man
+
+ddate:
+
+clean:
+	rm -f ddate
+
+install: ddate ddate.1
+	install -d ${PREFIX}/bin ${MANDIR}/man1
+	install ddate ${PREFIX}/bin
+	install -m 644 ddate.1 ${MANDIR}/man1
+
+uninstall:
+	rm -f ${PREFIX}/bin/ddate ${MANDIR}/man1/ddate.1
diff --git a/port/ddate/ddate.1 b/port/ddate/ddate.1
new file mode 100644
index 00000000..c340578f
--- /dev/null
+++ b/port/ddate/ddate.1
@@ -0,0 +1,117 @@
+.\" All Rites Reversed.  This file is in the PUBLIC DOMAIN.
+.\" Kallisti.
+.TH DDATE 1 "Bureaucracy 3161" "ddate" "Emperor Norton User Command"
+.SH NAME
+ddate \- convert Gregorian dates to Discordian dates
+.SH SYNOPSIS
+.B ddate
+.RI [ \fB+\fPformat]
+.RI [ date ]
+.SH DESCRIPTION
+.B ddate
+prints the date in Discordian date format.
+.PP
+If called with no arguments,
+.B ddate
+will get the current system date, convert this to the Discordian
+date format and print this on the standard output. Alternatively, a
+Gregorian date may be specified on the command line, in the form of a numerical
+day, month and year.
+.PP
+If a format string is specified, the Discordian date will be printed in
+a format specified by the string. This mechanism works similarly to the
+format string mechanism of
+.B date(1),
+only almost completely differently. The fields are:
+.IP %A
+Full name of the day of the week (i.e., Sweetmorn)
+.IP %a
+Abbreviated name of the day of the week (i.e., SM)
+.IP %B
+Full name of the season (i.e., Chaos)
+.IP %b
+Abbreviated name of the season (i.e., Chs)
+.IP %d
+Cardinal number of day in season (i.e., 23)
+.IP %e
+Ordinal number of day in season (i.e., 23rd)
+.IP %H
+Name of current Holyday, if any
+.IP %N
+Magic code to prevent rest of format from being printed unless today is
+a Holyday.
+.IP %n
+Newline
+.IP %t
+Tab
+.IP %X
+Number of days remaining until X-Day. (Not valid if the SubGenius options
+are not compiled in.)
+.IP %Y
+The year of our Lady Discord (i.e., 3182)
+.IP %{
+.IP %}
+Used to enclose the part of the string which is to be replaced with the
+words "St. Tib's Day" if the current day is St. Tib's Day.
+.IP %\.
+Try it and see.
+.bp
+.SH EXAMPLES
+.nf
+% ddate
+.br
+Sweetmorn, Bureaucracy 42, 3161 YOLD
+.PP
+% ddate +'Today is %{%A, the %e of %B%}, %Y. %N%nCelebrate %H'
+.br
+Today is Sweetmorn, the 42nd of Bureaucracy, 3161.
+.PP
+% ddate +"It's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 26 9 1995
+.br
+It's Prickle-Prickle, the 50th of Bureaucracy, 3161.
+.br
+Celebrate Bureflux
+.PP
+% ddate +"Today's %{%A, the %e of %B%}, %Y. %N%nCelebrate %H" 29 2 1996
+.br
+Today's St. Tib's Day, 3162.
+.br
+
+.SH BUGS
+
+.B ddate(1)
+will produce undefined behavior if asked to produce the date for St. Tib's
+day and its format string does not contain the St. Tib's Day delimiters
+%{ and %}.
+
+.SH NOTE
+
+After `X-Day' passed without incident, the Church of the SubGenius
+declared that it had got the year upside down - X-Day is actually in 8661 AD
+rather than 1998 AD.  Thus, the True X-Day is Cfn 40, 9827.
+
+.SH AUTHOR
+.nh
+Original program by Druel the Chaotic aka Jeremy Johnson (mpython@gnu.ai.mit.edu)
+.br
+Major rewrite by Lee H:. O:. Smith, KYTP, aka Andrew Bulhak (acb@dev.null.org)
+.br
+Gregorian B.C.E. dates fixed by Chaplain Nyan the Wiser, aka Dan Dart (ntw@dandart.co.uk)
+.br
+Five tons of flax.
+
+.SH DISTRIBUTION POLICY
+
+Public domain. All rites reversed.
+
+.SH SEE ALSO
+
+date(1),
+.br
+http://www.subgenius.com/
+.br
+Malaclypse the Younger,
+.I "Principia Discordia, Or How I Found Goddess And What I Did To Her When I Found Her"
+
+.SH AVAILABILITY
+The ddate command is available from https://github.com/bo0ts/ddate.
diff --git a/port/ddate/ddate.c b/port/ddate/ddate.c
new file mode 100644
index 00000000..c0a6bf37
--- /dev/null
+++ b/port/ddate/ddate.c
@@ -0,0 +1,399 @@
+/* $ DVCS ID: $jer|,523/lhos,KYTP!41023161\b"?" <<= DO NOT DELETE! */
+
+/* ddate.c .. converts boring normal dates to fun Discordian Date -><-
+   written  the 65th day of The Aftermath in the Year of Our Lady of 
+   Discord 3157 by Druel the Chaotic aka Jeremy Johnson aka
+   mpython@gnu.ai.mit.edu  
+      28 Sever St Apt #3
+      Worcester MA 01609
+
+   and I'm not responsible if this program messes anything up (except your 
+   mind, I'm responsible for that)
+
+   (k) YOLD 3161 and all time before and after.
+   Reprint, reuse, and recycle what you wish.
+   This program is in the public domain.  Distribute freely.  Or not.
+
+   Majorly hacked, extended and bogotified/debogotified on 
+   Sweetmorn, Bureaucracy 42, 3161 YOLD, by Lee H:. O:. Smith, KYTP, 
+   aka Andrew Bulhak, aka acb@dev.null.org
+
+   Slightly hackled and crackled by a sweet firey stove on
+   Boomtime, the 53rd day of Bureaucracy in the YOLD 3179,
+   by Chaplain Nyan the Wiser, aka Dan Dart, aka ntw@dandart.co.uk
+
+   and I'm not responsible if this program messes anything up (except your 
+   mind, I'm responsible for that) (and that goes for me as well --lhos)
+
+   Version history:
+   Bureflux 3161:      First release of enhanced ddate with format strings
+   59 Bcy, 3161:       PRAISE_BOB and KILL_BOB options split, other minor
+                       changes.
+   53 Bcy, 3179:       Fixed gregorian date conversions less than YOLD 1167
+
+   1999-02-22 Arkadiusz Miskiewicz <misiek@pld.ORG.PL>
+   - added Native Language Support
+
+   2000-03-17 Burt Holzman <holzman+ddate@gmail.com>
+   - added range checks for dates
+
+   2014-06-07 William Woodruff <william@tuffbizz.com>
+   - removed gettext dependent locale code
+
+   15th of Confusion, 3180:
+   - call out adherents of the wrong fruit
+
+   FIVE TONS OF FLAX
+*/
+
+/* configuration options  VVVVV   READ THIS!!! */
+
+/* If you wish ddate(1) to print the date in the same format as Druel's 
+ * original ddate when called in immediate mode, define OLD_IMMEDIATE_FMT 
+ */
+
+#define OLD_IMMEDIATE_FMT
+
+/* If you wish to use the US format for aneristic dates (m-d-y), as opposed to
+ * the Commonwealth format, define US_FORMAT.
+ */
+
+/* #define US_FORMAT */
+
+/* If you are ideologically, theologically or otherwise opposed to the 
+ * Church of the SubGenius and do not wish your copy of ddate(1) to contain
+ * code for counting down to X-Day, undefine KILL_BOB */
+
+#define KILL_BOB 13013
+
+/* If you wish ddate(1) to contain SubGenius slogans, define PRAISE_BOB */
+
+/*#define PRAISE_BOB 13013*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <stdio.h>
+
+
+// work around includes and defines from formerly c.h
+#ifndef ARRAY_SIZE
+# define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
+#endif
+
+/* &a[0] degrades to a pointer: a different type from an array */
+# define __must_be_array(a) \
+	BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(__typeof__(a), __typeof__(&a[0])))
+
+#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
+
+/* work around hacks for standalone package */
+#define PACKAGE "ddate"
+#define PACKAGE_STRING "Stand Alone"
+
+#ifndef __GNUC__
+#define inline /* foo */
+#endif
+
+#ifdef KILL_BOB
+int xday_countdown(int yday, int year);
+#endif
+
+
+/* string constants */
+
+char *day_long[5] = { 
+    "Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"
+};
+
+char *day_short[5] = {"SM","BT","PD","PP","SO"};
+
+char *season_long[5] = { 
+    "Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"
+};
+
+char *season_short[5] = {"Chs", "Dsc", "Cfn", "Bcy", "Afm"};
+
+char *holyday[5][2] = { 
+    { "Mungday", "Chaoflux" },
+    { "Mojoday", "Discoflux" },
+    { "Syaday",  "Confuflux" },
+    { "Zaraday", "Bureflux" },
+    { "Maladay", "Afflux" }
+};
+
+struct disc_time {
+    int season; /* 0-4 */
+    int day; /* 0-72 */
+    int yday; /* 0-365 */
+    int year; /* 3066- */
+};
+
+char *excl[] = {
+    "Hail Eris!", "All Hail Discordia!", "Kallisti!", "Fnord.", "Or not.",
+    "Wibble.", "Pzat!", "P'tang!", "Frink!",
+#ifdef PRAISE_BOB
+    "Slack!", "Praise \"Bob\"!", "Or kill me.",
+#endif /* PRAISE_BOB */
+    /* randomness, from the Net and other places. Feel free to add (after
+       checking with the relevant authorities, of course). */
+    "Grudnuk demand sustenance!", "Keep the Lasagna flying!",
+    "You are what you see.",
+    "Or is it?", "This statement is false.",
+    "Lies and slander, sire!", "Hee hee hee!",
+#if defined(linux) || defined (__linux__) || defined (__linux)
+    "Hail Eris, Hack Linux!",
+#elif defined(__APPLE__)
+    "This Fruit is not the True Fruit of Discord.",
+#endif
+    ""
+};
+
+char default_fmt[] = "%{%A, %B %d%}, %Y YOLD";
+char *default_immediate_fmt=
+#ifdef OLD_IMMEDIATE_FMT
+"Today is %{%A, the %e day of %B%} in the YOLD %Y%N%nCelebrate %H"
+#else
+default_fmt
+#endif
+;
+
+#define DY(y) (y+1166)
+
+static inline char *ending(int i) {
+	return i/10==1?"th":(i%10==1?"st":(i%10==2?"nd":(i%10==3?"rd":"th")));
+}
+
+static inline int leapp(int i) {
+	return (!(DY(i)%4))&&((DY(i)%100)||(!(DY(i)%400)));
+}
+
+/* select a random string */
+static inline char *sel(char **strings, int num) {
+	return(strings[random()%num]);
+}
+
+void print(struct disc_time,char **); /* old */
+void format(char *buf, const char* fmt, struct disc_time dt);
+/* read a fortune file */
+int load_fortunes(char *fn, char *delim, char** result);
+
+struct disc_time convert(int,int);
+struct disc_time makeday(int,int,int);
+
+int
+main (int argc, char *argv[]) {
+    time_t t;
+    struct tm *eris;
+    int bob,raw;
+    struct disc_time hastur;
+    char schwa[23*17], *fnord=0;
+    int pi;
+    char *progname, *p;
+
+    progname = argv[0];
+    if ((p = strrchr(progname, '/')) != NULL)
+	progname = p+1;
+
+    srandom(time(NULL));
+    /* do args here */
+    for(pi=1; pi<argc; pi++) {
+	switch(argv[pi][0]) {
+	case '+': fnord=argv[pi]+1; break;
+	case '-': 
+	    switch(argv[pi][1]) {
+	    case 'V':
+		printf(("%s (%s)\n"), progname, PACKAGE_STRING);
+	    default: goto usage;
+	    }
+	default: goto thud;
+	}
+    }
+
+  thud:
+    if (argc-pi==3){ 
+	int moe=atoi(argv[pi]), larry=atoi(argv[pi+1]), curly=atoi(argv[pi+2]);
+	hastur=makeday(
+#ifdef US_FORMAT
+	    moe,larry,
+#else
+	    larry,moe,
+#endif
+	    curly);
+	if (hastur.season == -1) {
+		printf("Invalid date -- out of range\n");
+		return -1;
+	}
+	fnord=fnord?fnord:default_fmt;
+    } else if (argc!=pi) { 
+      usage:
+	fprintf(stderr,("usage: %s [+format] [day month year]\n"), argv[0]);
+	exit(1);
+    } else {
+	t= time(NULL);
+	eris=localtime(&t);
+	bob=eris->tm_yday; /* days since Jan 1. */
+	raw=eris->tm_year; /* years since 1980 */
+	hastur=convert(bob,raw);
+	fnord=fnord?fnord:default_immediate_fmt;
+    }
+    format(schwa, fnord, hastur);
+    printf("%s\n", schwa);
+   
+    return 0;
+}
+
+void format(char *buf, const char* fmt, struct disc_time dt)
+{
+    int tib_start=-1, tib_end=0;
+    int i, fmtlen=strlen(fmt);
+    char *bufptr=buf;
+
+/*    fprintf(stderr, "format(%p, \"%s\", dt)\n", buf, fmt);*/
+
+    /* first, find extents of St. Tib's Day area, if defined */
+    for(i=0; i<fmtlen; i++) {
+	if(fmt[i]=='%') {
+	    switch(fmt[i+1]) {
+	    case 'A':
+	    case 'a':
+	    case 'd':
+	    case 'e':
+		if(tib_start>0)	    tib_end=i+1;
+		else		    tib_start=i;
+		break;
+	    case '{': tib_start=i; break;
+	    case '}': tib_end=i+1; break;
+	    }
+	}
+    }
+
+    /* now do the formatting */
+    buf[0]=0;
+
+    for(i=0; i<fmtlen; i++) {
+	if((i==tib_start) && (dt.day==-1)) {
+	    /* handle St. Tib's Day */
+	    strcpy(bufptr, ("St. Tib's Day"));
+	    bufptr += strlen(bufptr);
+	    i=tib_end;
+	} else {
+	    if(fmt[i]=='%') {
+		char *wibble=0, snarf[23];
+		switch(fmt[++i]) {
+		case 'A': wibble=day_long[dt.yday%5]; break;
+		case 'a': wibble=day_short[dt.yday%5]; break;
+		case 'B': wibble=season_long[dt.season]; break;
+		case 'b': wibble=season_short[dt.season]; break;
+		case 'd': sprintf(snarf, "%d", dt.day+1); wibble=snarf; break;
+		case 'e': sprintf(snarf, "%d%s", dt.day+1, ending(dt.day+1)); 
+		    wibble=snarf; break;
+		case 'H': if(dt.day==4||dt.day==49)
+		    wibble=holyday[dt.season][dt.day==49]; break;
+		case 'N': if(dt.day!=4&&dt.day!=49) goto eschaton; break;
+		case 'n': *(bufptr++)='\n'; break;
+		case 't': *(bufptr++)='\t'; break;
+
+		case 'Y': sprintf(snarf, "%d", dt.year); wibble=snarf; break;
+		case '.': wibble=sel(excl, ARRAY_SIZE(excl));
+		    break;
+#ifdef KILL_BOB
+		case 'X': sprintf(snarf, "%d", 
+				  xday_countdown(dt.yday, dt.year));
+				  wibble = snarf; break;
+#endif /* KILL_BOB */
+		}
+		if(wibble) {
+/*		    fprintf(stderr, "wibble = (%s)\n", wibble);*/
+		    strcpy(bufptr, wibble); bufptr+=strlen(wibble);
+		}
+	    } else {
+		*(bufptr++) = fmt[i];
+	    }
+	}
+    }
+  eschaton:
+    *(bufptr)=0;
+}
+
+struct disc_time makeday(int imonth,int iday,int iyear) /*i for input */
+{ 
+    struct disc_time funkychickens;
+    
+    int cal[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
+    int dayspast=0;
+
+    memset(&funkychickens,0,sizeof(funkychickens));
+    /* basic range checks */
+    if (imonth < 1 || imonth > 12 || iyear == 0) {
+	    funkychickens.season = -1;
+	    return funkychickens;
+    }
+    if (iday < 1 || iday > cal[imonth-1]) {
+	    if (!(imonth == 2 && iday == 29 && iyear%4 == 0 &&
+		  (iyear%100 != 0 || iyear%400 == 0))) {
+		    funkychickens.season = -1;
+		    return funkychickens;
+	    }
+    }
+    
+    imonth--;
+    /*  note: gregorian year 0 doesn't exist so
+     *  add one if user specifies a year less than 0 */
+    funkychickens.year= iyear+1166 + ((0 > iyear)?1:0);
+    while(imonth>0) { dayspast+=cal[--imonth]; }
+    funkychickens.day=dayspast+iday-1;
+    funkychickens.season=0;
+    if((funkychickens.year%4)==2) {
+	if (funkychickens.day==59 && iday==29)  funkychickens.day=-1;
+    }
+    funkychickens.yday=funkychickens.day;
+/*               note: EQUAL SIGN...hopefully that fixes it */
+    while(funkychickens.day>=73) {
+	funkychickens.season++;
+	funkychickens.day-=73;
+    }
+    return funkychickens;
+}
+
+struct disc_time convert(int nday, int nyear)
+{  struct disc_time funkychickens;
+   
+   funkychickens.year = nyear+3066;
+   funkychickens.day=nday;
+   funkychickens.season=0;
+   if ((funkychickens.year%4)==2)
+     {if (funkychickens.day==59)
+	funkychickens.day=-1;
+     else if (funkychickens.day >59)
+       funkychickens.day-=1;
+    }
+   funkychickens.yday=funkychickens.day;
+   while (funkychickens.day>=73)
+     { funkychickens.season++;
+       funkychickens.day-=73;
+     }
+   return funkychickens;
+  
+ }
+
+#ifdef KILL_BOB
+
+/* Code for counting down to X-Day, X-Day being Cfn 40, 3164 
+ *
+ * After `X-Day' passed without incident, the CoSG declared that it had 
+ * got the year upside down --- X-Day is actually in 8661 AD rather than 
+ * 1998 AD.
+ *
+ * Thus, the True X-Day is Cfn 40, 9827.
+ *
+ */
+
+int xday_countdown(int yday, int year) {
+    int r=(185-yday)+(((yday<59)&&(leapp(year)))?1:0);
+    while(year<9827) r+=(leapp(++year)?366:365);
+    while(year>9827) r-=(leapp(year--)?366:365);
+    return r;
+}
+
+#endif
diff --git a/port/wcwidth/.gitignore b/port/wcwidth/.gitignore
deleted file mode 100644
index aa25f78d..00000000
--- a/port/wcwidth/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-*.o
-*.dylib
diff --git a/port/wcwidth/Makefile b/port/wcwidth/Makefile
deleted file mode 100644
index f6932d6d..00000000
--- a/port/wcwidth/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-PREFIX = ~/.local
-
-OBJS = wcwidth.o wcswidth.o
-DYLIB = libwcwidth.dylib
-
-${DYLIB}: ${OBJS}
-	${CC} -dynamiclib ${LDFLAGS} ${OBJS} -o $@
-
-wcwidth.o: nonspacing.h wide.h
-
-clean:
-	rm -f ${DYLIB} ${OBJS}
-
-install: ${DYLIB}
-	install -d ${PREFIX}/lib
-	install -m 644 ${DYLIB} ${PREFIX}/lib
-
-uninstall:
-	rm -f ${PREFIX}/lib/${DYLIB}
diff --git a/port/wcwidth/nonspacing.h b/port/wcwidth/nonspacing.h
deleted file mode 100644
index 5d05a3d1..00000000
--- a/port/wcwidth/nonspacing.h
+++ /dev/null
@@ -1,89 +0,0 @@
-16,16,16,18,19,20,21,22,23,24,25,26,27,28,29,30,31,16,16,32,16,16,16,33,34,35,
-36,37,38,39,16,16,40,16,16,16,16,16,16,16,16,16,16,16,41,42,16,16,43,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,44,16,45,46,47,48,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,49,16,16,50,
-51,16,52,53,54,16,16,16,16,16,16,55,16,16,56,16,57,58,59,60,61,62,63,64,65,66,
-67,68,16,69,70,71,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,72,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,73,74,16,16,16,75,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,76,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,77,78,16,16,16,16,16,16,16,79,16,16,16,16,16,80,81,82,16,16,16,16,16,83,
-84,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,248,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,254,255,255,255,255,191,182,0,0,0,0,0,0,0,63,0,255,23,0,0,0,0,0,248,255,
-255,0,0,1,0,0,0,0,0,0,0,0,0,0,0,192,191,159,61,0,0,0,128,2,0,0,0,255,255,255,
-7,0,0,0,0,0,0,0,0,0,0,192,255,1,0,0,0,0,0,0,248,15,32,0,0,192,251,239,62,0,0,
-0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,255,255,255,255,
-255,7,0,0,0,0,0,0,20,254,33,254,0,12,0,0,0,2,0,0,0,0,0,0,16,30,32,0,0,12,0,0,
-64,6,0,0,0,0,0,0,16,134,57,2,0,0,0,35,0,6,0,0,0,0,0,0,16,190,33,0,0,12,0,0,
-252,2,0,0,0,0,0,0,144,30,32,64,0,12,0,0,0,4,0,0,0,0,0,0,0,1,32,0,0,0,0,0,0,17,
-0,0,0,0,0,0,192,193,61,96,0,12,0,0,0,2,0,0,0,0,0,0,144,64,48,0,0,12,0,0,0,3,0,
-0,0,0,0,0,24,30,32,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,4,92,0,0,0,0,0,0,0,0,0,0,0,
-242,7,128,127,0,0,0,0,0,0,0,0,0,0,0,0,242,31,0,63,0,0,0,0,0,0,0,0,0,3,0,0,160,
-2,0,0,0,0,0,0,254,127,223,224,255,254,255,255,255,31,64,0,0,0,0,0,0,0,0,0,0,0,
-0,224,253,102,0,0,0,195,1,0,30,0,100,32,0,32,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,
-0,0,28,0,0,0,12,0,0,0,12,0,0,0,0,0,0,0,176,63,64,254,15,32,0,0,0,0,0,120,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,1,4,14,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,9,0,0,0,0,0,0,64,127,
-229,31,248,159,0,0,0,0,0,0,255,127,0,0,0,0,0,0,0,0,15,0,0,0,0,0,208,23,4,0,0,
-0,0,248,15,0,3,0,0,0,60,59,0,0,0,0,0,0,64,163,3,0,0,0,0,0,0,240,207,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,247,255,253,33,16,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,
-251,0,248,0,0,0,124,0,0,0,0,0,0,223,255,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,
-255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0,
-0,60,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,128,247,63,0,0,0,192,0,0,0,0,0,0,0,0,0,0,3,0,68,8,0,0,96,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,48,0,0,0,255,255,3,128,0,0,0,0,192,63,0,0,128,255,3,0,
-0,0,0,0,7,0,0,0,0,0,200,51,0,0,0,0,32,0,0,0,0,0,0,0,0,126,102,0,8,16,0,0,0,0,
-0,16,0,0,0,0,0,0,157,193,2,0,0,0,0,48,64,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,33,0,0,0,0,0,64,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,0,0,255,255,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,110,240,0,0,0,0,0,135,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,
-0,0,0,0,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,192,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,255,
-127,0,0,0,0,0,0,128,3,0,0,0,0,0,120,38,0,32,0,0,0,0,0,0,7,0,0,0,128,239,31,0,
-0,0,0,0,0,0,8,0,3,0,0,0,0,0,192,127,0,30,0,0,0,0,0,0,0,0,0,0,0,128,211,64,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,248,7,0,0,3,0,0,0,0,0,0,24,1,0,0,0,192,
-31,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,92,0,0,64,0,0,0,0,0,
-0,0,0,0,0,248,133,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,60,176,1,0,0,48,0,0,0,
-0,0,0,0,0,0,0,248,167,1,0,0,0,0,0,0,0,0,0,0,0,0,40,191,0,0,0,0,0,0,0,0,0,0,0,
-0,224,188,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-128,255,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,12,1,0,0,0,254,7,0,0,0,0,248,121,128,0,
-126,14,0,0,0,0,0,252,127,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,191,0,0,0,
-0,0,0,0,0,0,0,252,255,255,252,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,126,180,191,0,
-0,0,0,0,0,0,0,0,163,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,
-0,0,0,0,0,0,0,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,127,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,
-0,128,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,15,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,248,255,231,15,0,0,0,60,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,255,255,255,255,255,255,127,248,255,255,255,255,255,31,32,0,16,0,0,248,
-254,255,0,0,0,0,0,0,0,0,0,
-0,127,255,255,249,219,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,0,240,7,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,
diff --git a/port/wcwidth/wcswidth.c b/port/wcwidth/wcswidth.c
deleted file mode 100644
index 5c8a5a4d..00000000
--- a/port/wcwidth/wcswidth.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <wchar.h>
-
-int wcswidth(const wchar_t *wcs, size_t n)
-{
-	int l=0, k=0;
-	for (; n-- && *wcs && (k = wcwidth(*wcs)) >= 0; l+=k, wcs++);
-	return (k < 0) ? k : l;
-}
diff --git a/port/wcwidth/wcwidth.c b/port/wcwidth/wcwidth.c
deleted file mode 100644
index 36256a53..00000000
--- a/port/wcwidth/wcwidth.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <wchar.h>
-
-static const unsigned char table[] = {
-#include "nonspacing.h"
-};
-
-static const unsigned char wtable[] = {
-#include "wide.h"
-};
-
-int wcwidth(wchar_t wc)
-{
-	if (wc < 0xffU)
-		return (wc+1 & 0x7f) >= 0x21 ? 1 : wc ? -1 : 0;
-	if ((wc & 0xfffeffffU) < 0xfffe) {
-		if ((table[table[wc>>8]*32+((wc&255)>>3)]>>(wc&7))&1)
-			return 0;
-		if ((wtable[wtable[wc>>8]*32+((wc&255)>>3)]>>(wc&7))&1)
-			return 2;
-		return 1;
-	}
-	if ((wc & 0xfffe) == 0xfffe)
-		return -1;
-	if (wc-0x20000U < 0x20000)
-		return 2;
-	if (wc == 0xe0001 || wc-0xe0020U < 0x5f || wc-0xe0100U < 0xef)
-		return 0;
-	return 1;
-}
diff --git a/port/wcwidth/wide.h b/port/wcwidth/wide.h
deleted file mode 100644
index e403c9a5..00000000
--- a/port/wcwidth/wide.h
+++ /dev/null
@@ -1,65 +0,0 @@
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,18,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,19,16,20,21,22,16,16,16,23,16,16,24,25,26,27,28,17,
-17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,29,
-17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
-17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
-17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
-17,17,17,17,17,17,17,17,30,16,16,16,16,31,16,16,17,17,17,17,17,17,17,17,17,17,
-17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
-17,17,17,17,17,17,17,32,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,16,16,16,33,
-34,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,35,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
-17,17,17,17,17,17,36,17,17,37,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,38,39,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
-16,16,16,16,16,16,16,40,41,42,43,44,45,46,47,16,48,49,16,16,16,16,
-16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,6,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,30,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,48,0,0,0,0,0,0,255,15,0,0,0,0,128,0,0,8,
-0,2,12,0,96,48,64,16,0,0,4,44,36,32,12,0,0,0,1,0,0,0,80,184,0,0,0,0,0,0,0,224,
-0,0,0,1,128,0,0,0,0,0,0,0,0,0,0,0,24,0,0,0,0,0,0,33,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,251,255,255,255,255,255,255,255,
-255,255,255,15,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-255,255,255,255,255,255,255,255,255,255,255,63,0,0,0,255,15,255,255,255,255,
-255,255,255,127,254,255,255,255,255,255,255,255,255,255,127,254,255,255,255,
-255,255,255,255,255,255,255,255,255,224,255,255,255,255,255,254,255,255,255,
-255,255,255,255,255,255,255,127,255,255,255,255,255,7,255,255,255,255,15,0,
-255,255,255,255,255,127,255,255,255,255,255,0,255,255,255,255,255,255,255,255,
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,
-0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-255,31,255,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,
-255,255,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,255,3,0,0,255,255,255,255,247,255,127,15,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,255,255,255,255,255,255,255,255,255,255,
-255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,255,255,255,255,255,255,255,255,255,255,255,
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-255,255,255,255,255,255,255,255,255,255,255,255,7,0,255,255,255,127,0,0,0,0,0,
-0,7,0,240,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-15,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,64,254,7,0,0,0,0,0,0,0,0,0,0,0,0,7,0,255,255,255,
-255,255,15,255,1,3,0,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,
-1,224,191,255,255,255,255,255,255,255,255,223,255,255,15,0,255,255,255,255,
-255,135,15,0,255,255,17,255,255,255,255,255,255,255,255,127,253,255,255,255,
-255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
-159,255,255,255,255,255,255,255,63,0,120,255,255,255,0,0,4,0,0,96,0,16,0,0,0,
-0,0,0,0,0,0,0,248,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,255,255,
-255,255,255,255,255,255,63,16,39,0,0,24,240,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,255,15,0,
-0,0,224,255,255,255,255,255,255,255,255,255,255,255,255,123,252,255,255,255,
-255,231,199,255,255,255,231,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,15,7,7,0,63,0,0,0,0,0,0,0,0,0,0,0,0,0,