fdports1.c: hacked in a gross fix for linux bug. The problem is that

linux stdio functions retry when interrupted, instead of returning
    errno=EINTR.

regexp: New regexp-substitute function.

scsh-interfaces: Fixed a typo in a type decl.
This commit is contained in:
shivers 1997-02-26 20:37:53 +00:00
parent 9ccd709a52
commit 66735d9c9e
4 changed files with 26 additions and 51 deletions

View File

@ -41,11 +41,15 @@ static FILE *fstar_cache[NUM_FDPORTS] = {NULL};
/* Maps fd's to ports. */
static scheme_value fdports[NUM_FDPORTS] = {SCHFALSE};
extern void remove_bone_from_head_of_linux_libc (void);
void init_fdports(void)
{
int i = NUM_FDPORTS;
while( i-- ) fdports[i] = SCHFALSE;
remove_bone_from_head_of_linux_libc();
/* Specially hack stdio. */
fstar_cache[fileno(stdin)] = stdin;
fstar_cache[fileno(stdout)] = stdout;

View File

@ -67,36 +67,6 @@ scheme_value df_re_match(long nargs, scheme_value *args)
return ret1;
}
scheme_value df_re_subst(long nargs, scheme_value *args)
{
extern char *re_subst(scheme_value , const char *, const char *, int , scheme_value , scheme_value , scheme_value , int *);
scheme_value ret1;
char *r1;
int r2;
cig_check_nargs(8, nargs, "re_subst");
r1 = re_subst(args[7], cig_string_body(args[6]), cig_string_body(args[5]), EXTRACT_FIXNUM(args[4]), args[3], args[2], args[1], &r2);
ret1 = VECTOR_REF(*args,0);
{AlienVal(CAR(ret1)) = (long) r1; CDR(ret1) = strlen_or_false(r1);}
VECTOR_REF(*args,1) = ENTER_FIXNUM(r2);
return ret1;
}
scheme_value df_re_subst_len(long nargs, scheme_value *args)
{
extern char *re_subst_len(scheme_value , const char *, const char *, int , scheme_value , scheme_value , int *);
scheme_value ret1;
char *r1;
int r2;
cig_check_nargs(7, nargs, "re_subst_len");
r1 = re_subst_len(args[6], cig_string_body(args[5]), cig_string_body(args[4]), EXTRACT_FIXNUM(args[3]), args[2], args[1], &r2);
ret1 = VECTOR_REF(*args,0);
{AlienVal(CAR(ret1)) = (long) r1; CDR(ret1) = strlen_or_false(r1);}
VECTOR_REF(*args,1) = ENTER_FIXNUM(r2);
return ret1;
}
scheme_value df_filter_stringvec(long nargs, scheme_value *args)
{
extern char *filter_stringvec(const char *, char const ** , int *);

View File

@ -111,31 +111,33 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (regexp-substitute port match . items)
(let ((str (regexp-match:string match))
(sv (regexp-match:start match))
(ev (regexp-match:end match)))
(let* ((str (regexp-match:string match))
(sv (regexp-match:start match))
(ev (regexp-match:end match))
(range (lambda (item) ; Return start & end of
(cond ((integer? item) ; ITEM's range in STR.
(values (vector-ref sv item)
(vector-ref ev item)))
((eq? 'pre item) (values 0 (vector-ref sv 0)))
((eq? 'post item) (values (vector-ref ev 0)
(string-length str)))
(else (error "Illegal substitution item."
item
regexp-substitute))))))
(if port
;; Output port case.
(for-each (lambda (item)
(cond ((string? item) (write-string item port))
((integer? item) (write-string str port
(vector-ref sv item)
(vector-ref ev item)))
(else (error "Illegal substitution item."
item
regexp-substitute))))
(if (string? item) (write-string item port)
(receive (si ei) (range item)
(write-string str port si ei))))
items)
;; Here's the string case. Make two passes -- one to
;; compute the length of the target string, one to fill it in.
(let* ((len (reduce (lambda (i item)
(+ i (cond ((string? item) (string-length item))
((integer? (- (vector-ref ev item)
(vector-ref sv item))))
(else (error "Illegal substitution item."
item
regexp-substitute)))))
(+ i (if (string? item) (string-length item)
(receive (si ei) (range item) (- ei si)))))
0 items))
(ans (make-string len)))
@ -143,8 +145,7 @@
(cond ((string? item)
(copy-string! ans index item)
(+ index (string-length item)))
(else (let ((si (vector-ref sv item))
(ei (vector-ref ev item)))
(else (receive (si ei) (range item)
(copy-substring! ans index str si ei)
(+ index (- ei si))))))
0 items)

View File

@ -96,8 +96,8 @@
(define-interface scsh-errors-interface
(export errno-error
error
(with-errno-handler* (proc (proc (:number :value) :values) ; handler
(proc () :values))) ; thunk
(with-errno-handler* (proc ((proc (:number :value) :values)); handler
(proc () :values))) ; thunk
(with-errno-handler :syntax)))
@ -424,7 +424,7 @@
make-regexp
regexp?
regexp-exec
regexp-subst
regexp-substitute
regexp-quote))