Introduction
Introduction Statistics Contact Development Disclaimer Help
Standardized on 16-bit shorts. - sam - An updated version of the sam text edito…
git clone git://vernunftzentrum.de/sam.git
Log
Files
Refs
LICENSE
---
commit 7827b57212dabd01b471b7ab821f1862b666dd07
parent 7db039abc42d7c4c57e80b7c3856938bae6ead98
Author: Rob King <[email protected]>
Date: Tue, 27 Sep 2016 11:21:48 -0500
Standardized on 16-bit shorts.
Diffstat:
include/frame.h | 22 +++++++++++-----------
include/libg.h | 2 +-
include/u.h | 1 -
libXg/gwin.c | 10 +++++-----
libXg/latin1.c | 12 +++++++-----
sam/file.c | 12 ++++++------
sam/mesg.c | 8 ++++----
sam/multi.c | 2 +-
sam/parse.h | 8 ++++----
sam/sam.h | 32 ++++++++++++++++----------------
samterm/menu.c | 2 +-
samterm/mesg.c | 4 ++--
samterm/samterm.h | 10 +++++-----
13 files changed, 63 insertions(+), 62 deletions(-)
---
diff --git a/include/frame.h b/include/frame.h
@@ -10,8 +10,8 @@ struct Frbox
union{
uchar *ptr;
struct{
- short bc; /* break char */
- short minwid;
+ int16_t bc; /* break char */
+ int16_t minwid;
} b;
} a;
};
@@ -28,15 +28,15 @@ struct Frame
Rectangle entire; /* of full frame */
Frbox *box;
uint64_t p0, p1; /* selection */
- short left; /* left edge of text */
- ushort nbox, nalloc;
- ushort maxtab; /* max size of tab, in pixels */
- ushort fheight; /* font height, in pixels */
- ushort nchars; /* # runes in frame */
- ushort nlines; /* # lines with text */
- ushort maxlines; /* total # lines in frame */
- ushort lastlinefull; /* last line fills frame */
- ushort modified; /* changed since frselect() */
+ int16_t left; /* left edge of text */
+ uint16_t nbox, nalloc;
+ uint16_t maxtab; /* max size of tab, in pixels */
+ uint16_t fheight; /* font height, in pixels */
+ uint16_t nchars; /* # runes in frame */
+ uint16_t nlines; /* # lines with text */
+ uint16_t maxlines; /* total # lines in frame */
+ uint16_t lastlinefull; /* last line fills frame */
+ uint16_t modified; /* changed since frselect() */
};
uint64_t frcharofpt(Frame*, Point);
diff --git a/include/libg.h b/include/libg.h
@@ -156,7 +156,7 @@ enum Fcode
typedef void (*Errfunc)(char *);
-extern void addlatin(char, char, short);
+extern void addlatin(char, char, int16_t);
extern Point add(Point, Point);
extern Point sub(Point, Point);
extern Point mul(Point, int);
diff --git a/include/u.h b/include/u.h
@@ -9,6 +9,5 @@
#include <unistd.h>
#include <wchar.h>
-typedef uint16_t ushort;
typedef uint8_t uchar;
typedef uint16_t Rune;
diff --git a/libXg/gwin.c b/libXg/gwin.c
@@ -164,7 +164,7 @@ Mappingaction(Widget w, XEvent *e, String *p, Cardinal *np)
typedef struct Unikeysym Unikeysym;
struct Unikeysym{
KeySym keysym;
- unsigned short value;
+ uint16_t value;
};
Unikeysym unikeysyms[] ={
@@ -172,7 +172,7 @@ Unikeysym unikeysyms[] ={
{0, 0}
};
-unsigned short
+uint16_t
keysymtoshort(KeySym k)
{
for (Unikeysym *ks = unikeysyms; ks->keysym != 0; ks++){
@@ -334,13 +334,13 @@ Keyaction(Widget w, XEvent *e, String *p, Cardinal *np)
if ((k < '0') || (k > 'f') ||
((k > '9') && (k < 'a'))) {
STUFFCOMPOSE();
- c = (unsigned short)k;
+ c = (uint16_t)k;
composing = -2;
} else if (composing == 4) {
c = unicode(compose);
if (c == -1) {
STUFFCOMPOSE();
- c = (unsigned short)compose[4];
+ c = (uint16_t)compose[4];
}
composing = -2;
}
@@ -348,7 +348,7 @@ Keyaction(Widget w, XEvent *e, String *p, Cardinal *np)
c = (int)latin1(compose);
if (c == -1) {
STUFFCOMPOSE();
- c = (unsigned short)compose[1];
+ c = (uint16_t)compose[1];
}
composing = -2;
}
diff --git a/libXg/latin1.c b/libXg/latin1.c
@@ -1,6 +1,8 @@
/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
-/* Changes copyright 2014-2014 Rob King. */
+/* Changes copyright 2014-2016 Rob King. */
+#include <inttypes.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -9,7 +11,7 @@
struct latin
{
- unsigned short l;
+ uint16_t l;
unsigned char c[2];
};
@@ -233,7 +235,7 @@ freelatin(void)
}
void
-addlatin(char c0, char c1, short l)
+addlatin(char c0, char c1, int16_t l)
{
static int i = 0;
@@ -263,8 +265,8 @@ initlatin(void)
return;
unsigned char c0, c1;
- unsigned short l;
- while (fscanf(keyboard, " %c%c %hx%*[^\n]\n", &c0, &c1, &l) == 3)
+ uint16_t l;
+ while (fscanf(keyboard, " %c%c %" SCNx16 "%*[^\n]\n", &c0, &c1, &l) == 3)
addlatin(c0, c1, l);
fclose(keyboard);
diff --git a/sam/file.c b/sam/file.c
@@ -10,9 +10,9 @@ static String *ftempstr(Rune*, int);
int fcount;
File *lastfile;
-void puthdr_csl(Buffer*, char, short, Posn);
-void puthdr_cs(Buffer*, char, short);
-void puthdr_M(Buffer*, Posn, Range, Range, Mod, short);
+void puthdr_csl(Buffer*, char, int16_t, Posn);
+void puthdr_cs(Buffer*, char, int16_t);
+void puthdr_M(Buffer*, Posn, Range, Range, Mod, int16_t);
void puthdr_cll(Buffer*, char, Posn, Posn);
void Fflush(File*);
@@ -351,7 +351,7 @@ Fupdate(File *f, int mktrans, int toterm)
}
void
-puthdr_csl(Buffer *b, char c, short s, Posn p)
+puthdr_csl(Buffer *b, char c, int16_t s, Posn p)
{
struct _csl buf;
@@ -364,7 +364,7 @@ puthdr_csl(Buffer *b, char c, short s, Posn p)
}
void
-puthdr_cs(Buffer *b, char c, short s)
+puthdr_cs(Buffer *b, char c, int16_t s)
{
struct _cs buf;
@@ -374,7 +374,7 @@ puthdr_cs(Buffer *b, char c, short s)
}
void
-puthdr_M(Buffer *b, Posn p, Range dot, Range mk, Mod m, short s1)
+puthdr_M(Buffer *b, Posn p, Range dot, Range mk, Mod m, int16_t s1)
{
Mark mark;
static int first = 1;
diff --git a/sam/mesg.c b/sam/mesg.c
@@ -88,7 +88,7 @@ void
journaln(int out, int64_t n)
{
char buf[32];
- sprint(buf, sizeof (int64_t) > 4 ? "%ld" : "%d", n);
+ sprint(buf, PRId64, n);
journal(out, buf);
}
#else
@@ -171,7 +171,7 @@ inmesg(Tmesg type)
{
Rune buf[1025];
int i, m;
- short s;
+ int16_t s;
int64_t l, l1, l2;
File *f;
Posn p0, p1;
@@ -449,7 +449,7 @@ inmesg(Tmesg type)
c = 0;
i = 0;
m = snarfbuf->nrunes;
- if(m > 32000) { /* tmprstr stores len in a short */
+ if(m > 32000) { /* tmprstr stores len in a int16_t */
m = 32000;
dprint("?warning: snarf buffer truncated\n");
}
@@ -516,7 +516,7 @@ snarf(File *f, Posn p1, Posn p2, Buffer *buf, int emptyok)
int
inshort(void)
{
- ushort n;
+ uint16_t n;
n = inp[0] | (inp[1]<<8);
inp += 2;
diff --git a/sam/multi.c b/sam/multi.c
@@ -4,7 +4,7 @@
#include <libgen.h>
List file;
-ushort tag;
+uint16_t tag;
File *
newfile(void)
diff --git a/sam/parse.h b/sam/parse.h
@@ -25,9 +25,9 @@ struct Cmd
Addr *addr; /* address for m, t */
} g;
Cmd *next; /* pointer to next element in {} */
- short num;
- ushort flag; /* whatever */
- ushort cmdc; /* command character; 'x' etc. */
+ int16_t num;
+ uint16_t flag; /* whatever */
+ uint16_t cmdc; /* command character; 'x' etc. */
};
#define ccmd g.cmd
@@ -35,7 +35,7 @@ struct Cmd
#define caddr g.addr
extern struct cmdtab{
- ushort cmdc; /* command character */
+ uint16_t cmdc; /* command character */
uchar text; /* takes a textual argument? */
uchar regexp; /* takes a regular expression? */
uchar addr; /* takes an address (m or t)? */
diff --git a/sam/sam.h b/sam/sam.h
@@ -21,7 +21,7 @@
#define STRSIZE (2*BLOCKSIZE)
typedef int64_t Posn; /* file position or address */
-typedef ushort Mod; /* modification number */
+typedef uint16_t Mod; /* modification number */
typedef struct Address Address;
typedef struct Block Block;
@@ -85,7 +85,7 @@ struct List /* code depends on a int64_t being able to hold a…
/*
* Block must fit in a int64_t because the list routines manage arrays of
* blocks. Two problems: some machines (e.g. Cray) can't pull this off
- * -- on them, use bitfields -- and the ushort bnum limits temp file sizes
+ * -- on them, use bitfields -- and the uint16_t bnum limits temp file sizes
* to about 200 megabytes. Advantages: small, simple code and small
* memory overhead. If you really want to edit huge files, making BLOCKSIZE
* bigger is the easiest way.
@@ -93,19 +93,19 @@ struct List /* code depends on a int64_t being able to hold…
* The necessary conditions are even stronger:
* sizeof(struct Block)==sizeof(int64_t)
* && the first 32 bits must hold bnum and nrunes.
-* When sizeof(ushort)+sizeof(short) < sizeof(int64_t),
+* When sizeof(uint16_t)+sizeof(int16_t) < sizeof(int64_t),
* add padding at the beginning on a little endian and at
* the end on a big endian, as shown below for the DEC Alpha.
*/
struct Block
{
#if USE64BITS == 1
- char pad[sizeof(int64_t)-sizeof(ushort)-sizeof(short)];
+ char pad[sizeof(int64_t)-sizeof(uint16_t)-sizeof(int16_t)];
#endif
- ushort bnum; /* absolute number on disk */
- short nrunes; /* runes stored in this block */
+ uint16_t bnum; /* absolute number on disk */
+ int16_t nrunes; /* runes stored in this block */
#if USE64BITS == 2
- char pad[sizeof(int64_t)-sizeof(ushort)-sizeof(short)];
+ char pad[sizeof(int64_t)-sizeof(uint16_t)-sizeof(int16_t)];
#endif
};
@@ -125,8 +125,8 @@ struct Disc
struct String
{
- short n;
- short size;
+ int16_t n;
+ int16_t size;
Rune *s;
};
@@ -156,7 +156,7 @@ struct File
Range mark; /* tagged spot in text (don't confuse with Mark) */
List *rasp; /* map of what terminal's got */
String name; /* file name */
- short tag; /* for communicating with terminal */
+ int16_t tag; /* for communicating with terminal */
char state; /* Clean, Dirty, Unread, or Readerr*/
char closeok; /* ok to close file? */
char deleted; /* delete at completion of command */
@@ -180,7 +180,7 @@ struct Mark
Range dot;
Range mark;
Mod m;
- short s1;
+ int16_t s1;
};
/*
@@ -191,18 +191,18 @@ union Hdr
{
struct _csl
{
- short c;
- short s;
+ int16_t c;
+ int16_t s;
int64_t l;
}csl;
struct _cs
{
- short c;
- short s;
+ int16_t c;
+ int16_t s;
}cs;
struct _cll
{
- short c;
+ int16_t c;
int64_t l;
int64_t l1;
}cll;
diff --git a/samterm/menu.c b/samterm/menu.c
@@ -8,7 +8,7 @@
uchar *name[MAXFILES]; /* first byte is ' ' or '\'': modified state */
Text *text[MAXFILES]; /* pointer to Text associated with file */
-ushort tag[MAXFILES]; /* text[i].tag, even if text[i] not defined */
+uint16_t tag[MAXFILES]; /* text[i].tag, even if text[i] not defined */
int nname;
int mw;
diff --git a/samterm/mesg.c b/samterm/mesg.c
@@ -10,11 +10,11 @@
extern char *exname;
extern Flayer *flast;
-#define HSIZE 3 /* Type + short count */
+#define HSIZE 3 /* Type + int16_t count */
Header h;
uchar indata[DATASIZE+1]; /* room for NUL */
uchar outdata[DATASIZE];
-short outcount;
+int16_t outcount;
int hversion;
void inmesg(Hmesg, int);
diff --git a/samterm/samterm.h b/samterm/samterm.h
@@ -56,14 +56,14 @@ struct Rasp
Section *sect;
};
-#define Untagged ((ushort)65535)
+#define Untagged ((uint16_t)65535)
struct Text
{
Rasp rasp;
- short nwin;
- short front; /* input window */
- ushort tag;
+ int16_t nwin;
+ int16_t front; /* input window */
+ uint16_t tag;
char lock;
Flayer l[NL]; /* screen storage */
};
@@ -80,7 +80,7 @@ enum Resource
extern Text *text[];
extern uchar *name[];
-extern ushort tag[];
+extern uint16_t tag[];
extern int nname;
extern unsigned int cursor;
extern Flayer *which;
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.