ref: c283bc1914975d2aef33f727066821535ee56ba7
parent: f2030e386371d32081f82f793c82ef6635ba04da
author: Jacob Moody <moody@posixcafe.org>
date: Mon Feb 13 19:25:51 EST 2023
initial port
--- a/clr.c
+++ b/clr.c
@@ -1,7 +1,7 @@
+#include <u.h>
+#include <libc.h>
#include <ctype.h>
#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
#include "post.h"
/* returns a static buffer */
--- a/dev.c
+++ b/dev.c
@@ -1,7 +1,7 @@
+#include <u.h>
+#include <libc.h>
#include <ctype.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include "post.h"
static char dev_dir[PATHLEN]; /* device directory */
--- a/dict.c
+++ b/dict.c
@@ -1,6 +1,6 @@
+#include <u.h>
+#include <libc.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include "post.h"
#define CNTMIN (1 << 10)
--- a/font.c
+++ b/font.c
@@ -1,7 +1,7 @@
/* font handling */
+#include <u.h>
+#include <libc.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include "post.h"
struct font {
--- a/iset.c
+++ b/iset.c
@@ -1,5 +1,5 @@
-#include <stdlib.h>
-#include <string.h>
+#include <u.h>
+#include <libc.h>
#include "post.h"
#define ALIGN(n, a) (((n) + (a) - 1) & ~((a) - 1))
@@ -43,7 +43,7 @@
int *iset_get(struct iset *iset, int key)
{
- return key >= 0 && key < iset->cnt ? iset->set[key] : NULL;
+ return key >= 0 && key < iset->cnt ? iset->set[key] : nil;
}
int iset_len(struct iset *iset, int key)
--- /dev/null
+++ b/mkfile
@@ -1,0 +1,24 @@
+</$objtype/mkfile
+
+FDIR=/sys/lib/neatroff/font
+MDIR=/sys/lib/neatroff/tmac
+
+CFLAGS=-Fpw -DTROFFFDIR="/sys/lib/neatroff/font"
+BIN=/$objtype/bin/
+TARG=\
+ ps\
+ pdf\
+
+OFILES=\
+ post.$O\
+ font.$O\
+ dev.$O\
+ clr.$O\
+ dict.$O\
+ iset.$O\
+ sbuf.$O\
+
+
+</sys/src/cmd/mkmany
+
+$O.pdf: pdfext.$O
--- a/pdf.c
+++ b/pdf.c
@@ -1,11 +1,8 @@
/* PDF post-processor functions */
+#include <u.h>
+#include <libc.h>
#include <ctype.h>
-#include <fcntl.h>
-#include <stdarg.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
#include "post.h"
static char pdf_title[256]; /* document title */
@@ -230,7 +227,7 @@
char buf[1 << 10];
int fntype = fonttype(font_path(fn));
if (fntype == '1' || fntype == 't') {
- int fd = open(font_path(fn), O_RDONLY);
+ int fd = open(font_path(fn), OREAD);
struct sbuf *ffsb = sbuf_make();
struct sbuf *sb = sbuf_make();
int l1 = 0, l2 = 0, l3 = 0;
@@ -707,7 +704,7 @@
int fd, nr;
/* reading the pdf file */
sb = sbuf_make();
- fd = open(pdf, O_RDONLY);
+ fd = open(pdf, OREAD);
while ((nr = read(fd, buf, sizeof(buf))) > 0)
sbuf_mem(sb, buf, nr);
close(fd);
--- a/pdfext.c
+++ b/pdfext.c
@@ -1,8 +1,8 @@
/* Parse and extract PDF objects */
+#include <u.h>
+#include <libc.h>
#include <ctype.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include "post.h"
/* the number white space characters */
@@ -178,8 +178,8 @@
{
int i;
for (i = 0; i < n; i++)
- if (*(unsigned char *) (m + n - 1 - i) == c)
- return m + n - 1 - i;
+ if (*(unsigned char *) ((uchar*)m + n - 1 - i) == c)
+ return (uchar*)m + n - 1 - i;
return NULL;
}
--- a/post.c
+++ b/post.c
@@ -15,10 +15,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <u.h>
+#include <libc.h>
#include <ctype.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include "post.h"
static char *ps_title; /* document title */
@@ -391,7 +391,7 @@
case 'i':
if (dev_open(postdir, postdev)) {
fprintf(stderr, "neatpost: cannot open device %s\n", postdev);
- exit(1);
+ exits(postdev);
}
docheader(ps_title, ps_pagewidth, ps_pageheight, ps_linewidth);
break;
@@ -543,7 +543,7 @@
void *mextend(void *old, long oldsz, long newsz, int memsz)
{
- void *new = malloc(newsz * memsz);
+ uchar *new = malloc(newsz * memsz);
memcpy(new, old, oldsz * memsz);
memset(new + oldsz * memsz, 0, (newsz - oldsz) * memsz);
free(old);
--- a/ps.c
+++ b/ps.c
@@ -1,8 +1,7 @@
+#include <u.h>
+#include <libc.h>
#include <ctype.h>
-#include <stdarg.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include "post.h"
static char ps_title[256]; /* document title */
--- a/sbuf.c
+++ b/sbuf.c
@@ -1,8 +1,7 @@
/* variable length string buffer */
-#include <stdarg.h>
+#include <u.h>
+#include <libc.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include "post.h"
#define SBUFSZ 128