Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/holzschu/ios_system
Browse files Browse the repository at this point in the history
  • Loading branch information
N-Holzschuch committed Jul 6, 2020
2 parents 9821dd4 + 0728b4c commit 8aa27be
Show file tree
Hide file tree
Showing 1,792 changed files with 665,006 additions and 494 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
/libutil/
/shell_cmds/
/text_cmds/
/network_cmds-543/
/ssh_keygen_110/

# Precompiled Headers
*.gch
Expand Down
25 changes: 25 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
REVIEWS !

- still crashing randomly. But less often.

- write Lua script for TeX format creation from fmtutil.cnf
- write Lua script for ls-lR generation (?)
- write Lua script for tlmgr update ?

- add file coordinator / file presenter stuff. Done
- add dlopen / dlsym / dlclose stuff ?
Would open the way for local compilers.

- e-mail Luigi Scarso

- Python: numpy, matplotlib make more sense inside Pythonista, seriously
- Stop trying to make it happen inside Blink, it won't, seriously. OK.

- keep adding strerror(errno) to all commands in ios_system. Except warnx, errx.
- swift programming?

- move to Swift? Why?
- git swift mapping? Hard.

- Jupyter ?

38 changes: 38 additions & 0 deletions TODO2
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
procfile("-")
then grep_open(NULL)

Now: grep is the first thread to reach phtread_start
And it has been "joined"
So the second thread never starts. Need to "not join".

If I don't join, by the time grep starts, everything has been erased.

So need to wait for the thread to be active, then release.


- replace STDIN_FILENO with fileno(thread_stdin). Can't use #define
- replace all isatty
- TODO: also TeX/LaTeX. Keep compatible?
- X move global variables to __thread for multi-calls.

- todo: add ID of stream to close to params (in and out)
- don't close streams equal to thread_stdout, someone else will.
- don't close threads for system(), only for popen. Will be hard.
- easy to close out-stream after popen, harder to close in-stream.

X __thread for all commands in all groups
! extern variables inside functions also
X continue testing
- create new patches for Python and Lua
- test if python now works with system(python) (ballsy)
X fileno(thread_stdout) does not exist.

- TODO (now):
X ssh + command (easy-ish).
X mercurial calls subprocess.Popen(), it seems.
X popen does not call posix_popen
X dup2 inside execute_child. To state "p2cread == (new process) stdin"
- can use that.
- Need to think about what Popen does.

X hg connects but doesn't read data / write ?
5 changes: 5 additions & 0 deletions awk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions awk/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// swift-tools-version:5.2
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "awk",
// thread-local variables are only available with iOS 11+. This setting is required for compilation.
platforms: [.iOS(.v11)],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "awk",
targets: ["awk"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
// Depends on the local package, ios_system:
.package(path: "../ios_system")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "awk",
dependencies: ["ios_system"],
exclude: [],
cSettings: [.headerSearchPath("../"),
.headerSearchPath("./"),
],
linkerSettings: [.linkedFramework("ios_system")]
),
]
)
3 changes: 3 additions & 0 deletions awk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# awk

A description of this package.
235 changes: 235 additions & 0 deletions awk/Sources/awk/awk.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name Lucent Technologies or any of
its entities not be used in advertising or publicity pertaining
to distribution of the software without specific, written prior
permission.
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/

#include <assert.h>

typedef double Awkfloat;

/* unsigned char is more trouble than it's worth */

typedef unsigned char uschar;

#define xfree(a) { if ((a) != NULL) { free((void *) (a)); (a) = NULL; } }

#define NN(p) ((p) ? (p) : "(null)") /* guaranteed non-null for dprintf
*/
#define DEBUG
#ifdef DEBUG
/* uses have to be doubly parenthesized */
# define dprintf(x) if (dbg) fprintf x
#else
# define dprintf(x)
#endif

extern __thread int compile_time; /* 1 if compiling, 0 if running */
extern __thread int safe; /* 0 => unsafe, 1 => safe */
extern __thread int Unix2003_compat;

#define RECSIZE (8 * 1024) /* sets limit on records, fields, etc., etc. */
extern __thread int recsize; /* size of current record, orig RECSIZE */

extern __thread char **FS;
extern __thread char **RS;
extern __thread char **ORS;
extern __thread char **OFS;
extern __thread char **OFMT;
extern __thread Awkfloat *NR;
extern __thread Awkfloat *FNR;
extern __thread Awkfloat *NF;
extern __thread char **FILENAME;
extern __thread char **SUBSEP;
extern __thread Awkfloat *RSTART;
extern __thread Awkfloat *RLENGTH;

extern __thread char *record; /* points to $0 */
extern __thread int lineno; /* line number in awk program */
extern __thread int errorflag; /* 1 if error has occurred */
extern __thread int donefld; /* 1 if record broken into fields */
extern __thread int donerec; /* 1 if record is valid (no fld has changed */
extern __thread char inputFS[]; /* FS at time of input, for field splitting */

extern __thread int dbg;

extern __thread char *patbeg; /* beginning of pattern matched */
extern __thread int patlen; /* length of pattern matched. set in b.c */

/* Cell: all information about a variable or constant */

typedef struct Cell {
uschar ctype; /* OCELL, OBOOL, OJUMP, etc. */
uschar csub; /* CCON, CTEMP, CFLD, etc. */
char *nval; /* name, for variables only */
char *sval; /* string value */
Awkfloat fval; /* value as number */
int tval; /* type info: STR|NUM|ARR|FCN|FLD|CON|DONTFREE */
struct Cell *cnext; /* ptr to next if chained */
} Cell;

typedef struct Array { /* symbol table array */
int nelem; /* elements in table right now */
int size; /* size of tab */
Cell **tab; /* hash table pointers */
} Array;

#define NSYMTAB 50 /* initial size of a symbol table */
extern __thread Array *symtab;

extern __thread Cell *nrloc; /* NR */
extern __thread Cell *fnrloc; /* FNR */
extern __thread Cell *nfloc; /* NF */
extern __thread Cell *rstartloc; /* RSTART */
extern __thread Cell *rlengthloc; /* RLENGTH */

/* Cell.tval values: */
#define NUM 01 /* number value is valid */
#define STR 02 /* string value is valid */
#define DONTFREE 04 /* string space is not freeable */
#define CON 010 /* this is a constant */
#define ARR 020 /* this is an array */
#define FCN 040 /* this is a function name */
#define FLD 0100 /* this is a field $1, $2, ... */
#define REC 0200 /* this is $0 */


/* function types */
#define FLENGTH 1
#define FSQRT 2
#define FEXP 3
#define FLOG 4
#define FINT 5
#define FSYSTEM 6
#define FRAND 7
#define FSRAND 8
#define FSIN 9
#define FCOS 10
#define FATAN 11
#define FTOUPPER 12
#define FTOLOWER 13
#define FFLUSH 14

/* Node: parse tree is made of nodes, with Cell's at bottom */

typedef struct Node {
int ntype;
struct Node *nnext;
int lineno;
int nobj;
int nnarg;
struct Node *narg[1]; /* variable: actual size set by calling malloc */
} Node;

#define NIL ((Node *) 0)

extern __thread Node *winner;
extern __thread Node *nullstat;
extern __thread Node *nullnode;

/* ctypes */
#define OCELL 1
#define OBOOL 2
#define OJUMP 3

/* Cell subtypes: csub */
#define CFREE 7
#define CCOPY 6
#define CCON 5
#define CTEMP 4
#define CNAME 3
#define CVAR 2
#define CFLD 1
#define CUNK 0

/* bool subtypes */
#define BTRUE 11
#define BFALSE 12

/* jump subtypes */
#define JEXIT 21
#define JNEXT 22
#define JBREAK 23
#define JCONT 24
#define JRET 25
#define JNEXTFILE 26

/* node types */
#define NVALUE 1
#define NSTAT 2
#define NEXPR 3


extern __thread int pairstack[], paircnt;

#define notlegal(n) (n <= FIRSTTOKEN || n >= LASTTOKEN || proctab[n-FIRSTTOKEN] == nullproc)
#define isvalue(n) ((n)->ntype == NVALUE)
#define isexpr(n) ((n)->ntype == NEXPR)
#define isjump(n) ((n)->ctype == OJUMP)
#define isexit(n) ((n)->csub == JEXIT)
#define isbreak(n) ((n)->csub == JBREAK)
#define iscont(n) ((n)->csub == JCONT)
#define isnext(n) ((n)->csub == JNEXT || (n)->csub == JNEXTFILE)
#define isret(n) ((n)->csub == JRET)
#define isrec(n) ((n)->tval & REC)
#define isfld(n) ((n)->tval & FLD)
#define isstr(n) ((n)->tval & STR)
#define isnum(n) ((n)->tval & NUM)
#define isarr(n) ((n)->tval & ARR)
#define isfcn(n) ((n)->tval & FCN)
#define istrue(n) ((n)->csub == BTRUE)
#define istemp(n) ((n)->csub == CTEMP)
#define isargument(n) ((n)->nobj == ARG)
/* #define freeable(p) (!((p)->tval & DONTFREE)) */
#define freeable(p) ( ((p)->tval & (STR|DONTFREE)) == STR )

/* structures used by regular expression matching machinery, mostly b.c: */

#define NCHARS (256+3) /* 256 handles 8-bit chars; 128 does 7-bit */
/* watch out in match(), etc. */
#define NSTATES 32

typedef struct rrow {
long ltype; /* long avoids pointer warnings on 64-bit */
union {
int i;
Node *np;
uschar *up;
} lval; /* because Al stores a pointer in it! */
int *lfollow;
} rrow;

typedef struct fa {
uschar gototab[NSTATES][NCHARS];
uschar out[NSTATES];
uschar *restr;
int *posns[NSTATES];
int anchor;
int use;
int initstat;
int curstat;
int accept;
int reset;
struct rrow re[1]; /* variable: actual size set by calling malloc */
} fa;


#include "proto.h"
Loading

0 comments on commit 8aa27be

Please sign in to comment.