Zhong Shao performed much of the experimentation that led to the
current typed allocation facility. (His dynamic type inference code hasn't
made it into the released version of the collector, yet.)
+
+More contributors:
+Andrej Cedilnik <acedil1@csee.umbc.edu>
+Bradley D. LaRonde
+Grzegorz Jakacki <jakacki@acm.org>
+Margaret Fleck
+Oliver Kurth <oliver.kurth@innominate.com>
+Petter Urkedal <paurkedal@gmail.com>
+Rob Haack <rhaack@polaris.unm.edu>
+Tilman Vogel <Tilman.Vogel@web.de>
+Tom Tromey
# Permission to modify the code and to distribute modified code is granted,
# provided the above notices are retained, and a notice that the code was
# modified is included with the above copyright notice.
-#
-# Original author: Tom Tromey
-# Severely truncated by Hans-J. Boehm
-# Modified by: Grzegorz Jakacki <jakacki at acm dot org>
-# Modified by: Petter Urkedal <petter.urkedal@nordita.dk> (2005-04)
## Process this file with automake to produce Makefile.in.
ACLOCAL_AMFLAGS = -I m4
AM_CPPFLAGS = \
- -I$(top_builddir)/include -I$(top_srcdir)/include \
- $(ATOMIC_OPS_CFLAGS)
+ -I$(top_builddir)/include -I$(top_srcdir)/include \
+ $(ATOMIC_OPS_CFLAGS)
# Initialize variables so that we can declare files locally.
EXTRA_DIST =
lib_LTLIBRARIES += libgc.la
libgc_la_SOURCES = \
- allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c \
- dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c \
- malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c \
- obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c \
- specific.c stubborn.c typd_mlc.c \
- backgraph.c thread_local_alloc.c
+ allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c \
+ dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c \
+ malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c \
+ obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c \
+ specific.c stubborn.c typd_mlc.c \
+ backgraph.c thread_local_alloc.c
# C Library: Architecture Dependent
# ---------------------------------
## We need to add DEFS to assembler flags
## :FIXME: what if assembler does not accept -D... ?
-## (use Autoconf to prepare ASDEFS ???)
+## (use Autoconf to prepare ASDEFS?)
CCASFLAGS += $(DEFS)
# other makefiles
# :GOTCHA: deliberately we do not include 'Makefile'
EXTRA_DIST += BCC_MAKEFILE NT_MAKEFILE \
- OS2_MAKEFILE PCR-Makefile digimars.mak EMX_MAKEFILE \
+ OS2_MAKEFILE PCR-Makefile digimars.mak EMX_MAKEFILE \
Makefile.direct Makefile.dj Makefile.DLLs SMakefile.amiga \
WCC_MAKEFILE autogen.sh build_atomic_ops.sh build_atomic_ops.sh.cygwin \
NT_STATIC_THREADS_MAKEFILE NT_X64_STATIC_THREADS_MAKEFILE \
# Permission to modify the code and to distribute modified code is granted,
# provided the above notices are retained, and a notice that the code was
# modified is included with the above copyright notice.
-#
-# Original author: Tom Tromey
-# Modified by: Grzegorz Jakacki <jakacki at acm dot org>
dnl Process this file with autoconf to produce configure.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
- *
- * Author: Hans-J. Boehm (boehm@parc.xerox.com)
*/
-/* Boehm, October 3, 1994 5:19 pm PDT */
+
# include "gc.h"
# include "cord.h"
# include <stdlib.h>
-/*
+/*
* Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* An sprintf implementation that understands cords. This is probably */
-/* not terribly portable. It assumes an ANSI stdarg.h. It further */
-/* assumes that I can make copies of va_list variables, and read */
-/* arguments repeatedly by applyting va_arg to the copies. This */
-/* could be avoided at some performance cost. */
-/* We also assume that unsigned and signed integers of various kinds */
-/* have the same sizes, and can be cast back and forth. */
-/* We assume that void * and char * have the same size. */
-/* All this cruft is needed because we want to rely on the underlying */
-/* sprintf implementation whenever possible. */
-/* Boehm, September 21, 1995 6:00 pm PDT */
+/* An sprintf implementation that understands cords. This is probably */
+/* not terribly portable. It assumes an ANSI stdarg.h. It further */
+/* assumes that I can make copies of va_list variables, and read */
+/* arguments repeatedly by applying va_arg to the copies. This */
+/* could be avoided at some performance cost. */
+/* We also assume that unsigned and signed integers of various kinds */
+/* have the same sizes, and can be cast back and forth. */
+/* We assume that void * and char * have the same size. */
+/* All this cruft is needed because we want to rely on the underlying */
+/* sprintf implementation whenever possible. */
#include "cord.h"
#include "ec.h"
#include <string.h>
#include "gc.h"
-#define CONV_SPEC_LEN 50 /* Maximum length of a single */
- /* conversion specification. */
-#define CONV_RESULT_LEN 50 /* Maximum length of any */
- /* conversion with default */
- /* width and prec. */
+#define CONV_SPEC_LEN 50 /* Maximum length of a single */
+ /* conversion specification. */
+#define CONV_RESULT_LEN 50 /* Maximum length of any */
+ /* conversion with default */
+ /* width and prec. */
static int ec_len(CORD_ec x)
return(CORD_len(x[0].ec_cord) + (x[0].ec_bufptr - x[0].ec_buf));
}
-/* Possible nonumeric precision values. */
+/* Possible nonumeric precision values. */
# define NONE -1
# define VARIABLE -2
-/* Copy the conversion specification from CORD_pos into the buffer buf */
-/* Return negative on error. */
-/* Source initially points one past the leading %. */
-/* It is left pointing at the conversion type. */
-/* Assign field width and precision to *width and *prec. */
-/* If width or prec is *, VARIABLE is assigned. */
-/* Set *left to 1 if left adjustment flag is present. */
-/* Set *long_arg to 1 if long flag ('l' or 'L') is present, or to */
-/* -1 if 'h' is present. */
+/* Copy the conversion specification from CORD_pos into the buffer buf */
+/* Return negative on error. */
+/* Source initially points one past the leading %. */
+/* It is left pointing at the conversion type. */
+/* Assign field width and precision to *width and *prec. */
+/* If width or prec is *, VARIABLE is assigned. */
+/* Set *left to 1 if left adjustment flag is present. */
+/* Set *long_arg to 1 if long flag ('l' or 'L') is present, or to */
+/* -1 if 'h' is present. */
static int extract_conv_spec(CORD_pos source, char *buf,
- int * width, int *prec, int *left, int * long_arg)
+ int * width, int *prec, int *left, int * long_arg)
{
register int result = 0;
register int current_number = 0;
register int saw_number = 0;
register int chars_so_far = 0;
register char current;
-
+
*width = NONE;
buf[chars_so_far++] = '%';
while(CORD_pos_valid(source)) {
current = CORD_pos_fetch(source);
buf[chars_so_far++] = current;
switch(current) {
- case '*':
- saw_number = 1;
- current_number = VARIABLE;
- break;
+ case '*':
+ saw_number = 1;
+ current_number = VARIABLE;
+ break;
case '0':
if (!saw_number) {
/* Zero fill flag; ignore */
break;
} /* otherwise fall through: */
case '1':
- case '2':
- case '3':
- case '4':
- case '5':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
case '6':
- case '7':
- case '8':
- case '9':
- saw_number = 1;
- current_number *= 10;
- current_number += current - '0';
- break;
- case '.':
- saw_period = 1;
- if(saw_number) {
- *width = current_number;
- saw_number = 0;
- }
- current_number = 0;
- break;
- case 'l':
- case 'L':
- *long_arg = 1;
- current_number = 0;
- break;
- case 'h':
- *long_arg = -1;
- current_number = 0;
- break;
- case ' ':
- case '+':
- case '#':
- current_number = 0;
- break;
- case '-':
- *left = 1;
- current_number = 0;
- break;
- case 'd':
- case 'i':
- case 'o':
- case 'u':
- case 'x':
- case 'X':
- case 'f':
- case 'e':
- case 'E':
- case 'g':
- case 'G':
- case 'c':
- case 'C':
- case 's':
- case 'S':
- case 'p':
- case 'n':
- case 'r':
- goto done;
+ case '7':
+ case '8':
+ case '9':
+ saw_number = 1;
+ current_number *= 10;
+ current_number += current - '0';
+ break;
+ case '.':
+ saw_period = 1;
+ if(saw_number) {
+ *width = current_number;
+ saw_number = 0;
+ }
+ current_number = 0;
+ break;
+ case 'l':
+ case 'L':
+ *long_arg = 1;
+ current_number = 0;
+ break;
+ case 'h':
+ *long_arg = -1;
+ current_number = 0;
+ break;
+ case ' ':
+ case '+':
+ case '#':
+ current_number = 0;
+ break;
+ case '-':
+ *left = 1;
+ current_number = 0;
+ break;
+ case 'd':
+ case 'i':
+ case 'o':
+ case 'u':
+ case 'x':
+ case 'X':
+ case 'f':
+ case 'e':
+ case 'E':
+ case 'g':
+ case 'G':
+ case 'c':
+ case 'C':
+ case 's':
+ case 'S':
+ case 'p':
+ case 'n':
+ case 'r':
+ goto done;
default:
return(-1);
}
return(-1);
done:
if (saw_number) {
- if (saw_period) {
- *prec = current_number;
- } else {
- *prec = NONE;
- *width = current_number;
- }
+ if (saw_period) {
+ *prec = current_number;
+ } else {
+ *prec = NONE;
+ *width = current_number;
+ }
} else {
- *prec = NONE;
+ *prec = NONE;
}
buf[chars_so_far] = '\0';
return(result);
register char current;
CORD_pos pos;
char conv_spec[CONV_SPEC_LEN + 1];
-
+
CORD_ec_init(result);
for (CORD_set_pos(pos, format, 0); CORD_pos_valid(pos); CORD_next(pos)) {
- current = CORD_pos_fetch(pos);
- if (current == '%') {
+ current = CORD_pos_fetch(pos);
+ if (current == '%') {
CORD_next(pos);
if (!CORD_pos_valid(pos)) return(-1);
current = CORD_pos_fetch(pos);
if (current == '%') {
- CORD_ec_append(result, current);
+ CORD_ec_append(result, current);
} else {
- int width, prec;
- int left_adj = 0;
- int long_arg = 0;
- CORD arg;
- size_t len;
-
- if (extract_conv_spec(pos, conv_spec,
- &width, &prec,
- &left_adj, &long_arg) < 0) {
- return(-1);
- }
- current = CORD_pos_fetch(pos);
- switch(current) {
- case 'n':
- /* Assign length to next arg */
- if (long_arg == 0) {
- int * pos_ptr;
- pos_ptr = va_arg(args, int *);
- *pos_ptr = ec_len(result);
- } else if (long_arg > 0) {
- long * pos_ptr;
- pos_ptr = va_arg(args, long *);
- *pos_ptr = ec_len(result);
- } else {
- short * pos_ptr;
- pos_ptr = va_arg(args, short *);
- *pos_ptr = ec_len(result);
- }
- goto done;
- case 'r':
- /* Append cord and any padding */
- if (width == VARIABLE) width = va_arg(args, int);
- if (prec == VARIABLE) prec = va_arg(args, int);
- arg = va_arg(args, CORD);
- len = CORD_len(arg);
- if (prec != NONE && len > prec) {
- if (prec < 0) return(-1);
- arg = CORD_substr(arg, 0, prec);
- len = prec;
- }
- if (width != NONE && len < width) {
- char * blanks = GC_MALLOC_ATOMIC(width-len+1);
+ int width, prec;
+ int left_adj = 0;
+ int long_arg = 0;
+ CORD arg;
+ size_t len;
+
+ if (extract_conv_spec(pos, conv_spec,
+ &width, &prec,
+ &left_adj, &long_arg) < 0) {
+ return(-1);
+ }
+ current = CORD_pos_fetch(pos);
+ switch(current) {
+ case 'n':
+ /* Assign length to next arg */
+ if (long_arg == 0) {
+ int * pos_ptr;
+ pos_ptr = va_arg(args, int *);
+ *pos_ptr = ec_len(result);
+ } else if (long_arg > 0) {
+ long * pos_ptr;
+ pos_ptr = va_arg(args, long *);
+ *pos_ptr = ec_len(result);
+ } else {
+ short * pos_ptr;
+ pos_ptr = va_arg(args, short *);
+ *pos_ptr = ec_len(result);
+ }
+ goto done;
+ case 'r':
+ /* Append cord and any padding */
+ if (width == VARIABLE) width = va_arg(args, int);
+ if (prec == VARIABLE) prec = va_arg(args, int);
+ arg = va_arg(args, CORD);
+ len = CORD_len(arg);
+ if (prec != NONE && len > prec) {
+ if (prec < 0) return(-1);
+ arg = CORD_substr(arg, 0, prec);
+ len = prec;
+ }
+ if (width != NONE && len < width) {
+ char * blanks = GC_MALLOC_ATOMIC(width-len+1);
- memset(blanks, ' ', width-len);
- blanks[width-len] = '\0';
- if (left_adj) {
- arg = CORD_cat(arg, blanks);
- } else {
- arg = CORD_cat(blanks, arg);
- }
- }
- CORD_ec_append_cord(result, arg);
- goto done;
- case 'c':
- if (width == NONE && prec == NONE) {
- register char c;
+ memset(blanks, ' ', width-len);
+ blanks[width-len] = '\0';
+ if (left_adj) {
+ arg = CORD_cat(arg, blanks);
+ } else {
+ arg = CORD_cat(blanks, arg);
+ }
+ }
+ CORD_ec_append_cord(result, arg);
+ goto done;
+ case 'c':
+ if (width == NONE && prec == NONE) {
+ register char c;
- c = (char)va_arg(args, int);
- CORD_ec_append(result, c);
- goto done;
- }
- break;
- case 's':
- if (width == NONE && prec == NONE) {
- char * str = va_arg(args, char *);
- register char c;
+ c = (char)va_arg(args, int);
+ CORD_ec_append(result, c);
+ goto done;
+ }
+ break;
+ case 's':
+ if (width == NONE && prec == NONE) {
+ char * str = va_arg(args, char *);
+ register char c;
- while ((c = *str++)) {
- CORD_ec_append(result, c);
- }
- goto done;
- }
- break;
- default:
- break;
- }
- /* Use standard sprintf to perform conversion */
- {
- register char * buf;
- va_list vsprintf_args;
- int max_size = 0;
- int res;
-# ifdef __va_copy
+ while ((c = *str++)) {
+ CORD_ec_append(result, c);
+ }
+ goto done;
+ }
+ break;
+ default:
+ break;
+ }
+ /* Use standard sprintf to perform conversion */
+ {
+ register char * buf;
+ va_list vsprintf_args;
+ int max_size = 0;
+ int res;
+# ifdef __va_copy
__va_copy(vsprintf_args, args);
-# else
-# if defined(__GNUC__) && !defined(__DJGPP__) /* and probably in other cases */
+# else
+# if defined(__GNUC__) && !defined(__DJGPP__) /* and probably in other cases */
va_copy(vsprintf_args, args);
-# else
- vsprintf_args = args;
-# endif
-# endif
- if (width == VARIABLE) width = va_arg(args, int);
- if (prec == VARIABLE) prec = va_arg(args, int);
- if (width != NONE) max_size = width;
- if (prec != NONE && prec > max_size) max_size = prec;
- max_size += CONV_RESULT_LEN;
- if (max_size >= CORD_BUFSZ) {
- buf = GC_MALLOC_ATOMIC(max_size + 1);
- } else {
- if (CORD_BUFSZ - (result[0].ec_bufptr-result[0].ec_buf)
- < max_size) {
- CORD_ec_flush_buf(result);
- }
- buf = result[0].ec_bufptr;
- }
- switch(current) {
- case 'd':
- case 'i':
- case 'o':
- case 'u':
- case 'x':
- case 'X':
- case 'c':
- if (long_arg <= 0) {
- (void) va_arg(args, int);
- } else if (long_arg > 0) {
- (void) va_arg(args, long);
- }
- break;
- case 's':
- case 'p':
- (void) va_arg(args, char *);
- break;
- case 'f':
- case 'e':
- case 'E':
- case 'g':
- case 'G':
- (void) va_arg(args, double);
- break;
- default:
- return(-1);
- }
- res = vsprintf(buf, conv_spec, vsprintf_args);
- len = (size_t)res;
- if ((char *)(GC_word)res == buf) {
- /* old style vsprintf */
- len = strlen(buf);
- } else if (res < 0) {
- return(-1);
- }
- if (buf != result[0].ec_bufptr) {
- register char c;
+# else
+ vsprintf_args = args;
+# endif
+# endif
+ if (width == VARIABLE) width = va_arg(args, int);
+ if (prec == VARIABLE) prec = va_arg(args, int);
+ if (width != NONE) max_size = width;
+ if (prec != NONE && prec > max_size) max_size = prec;
+ max_size += CONV_RESULT_LEN;
+ if (max_size >= CORD_BUFSZ) {
+ buf = GC_MALLOC_ATOMIC(max_size + 1);
+ } else {
+ if (CORD_BUFSZ - (result[0].ec_bufptr-result[0].ec_buf)
+ < max_size) {
+ CORD_ec_flush_buf(result);
+ }
+ buf = result[0].ec_bufptr;
+ }
+ switch(current) {
+ case 'd':
+ case 'i':
+ case 'o':
+ case 'u':
+ case 'x':
+ case 'X':
+ case 'c':
+ if (long_arg <= 0) {
+ (void) va_arg(args, int);
+ } else if (long_arg > 0) {
+ (void) va_arg(args, long);
+ }
+ break;
+ case 's':
+ case 'p':
+ (void) va_arg(args, char *);
+ break;
+ case 'f':
+ case 'e':
+ case 'E':
+ case 'g':
+ case 'G':
+ (void) va_arg(args, double);
+ break;
+ default:
+ return(-1);
+ }
+ res = vsprintf(buf, conv_spec, vsprintf_args);
+ len = (size_t)res;
+ if ((char *)(GC_word)res == buf) {
+ /* old style vsprintf */
+ len = strlen(buf);
+ } else if (res < 0) {
+ return(-1);
+ }
+ if (buf != result[0].ec_bufptr) {
+ register char c;
- while ((c = *buf++)) {
- CORD_ec_append(result, c);
- }
- } else {
- result[0].ec_bufptr = buf + len;
- }
- }
+ while ((c = *buf++)) {
+ CORD_ec_append(result, c);
+ }
+ } else {
+ result[0].ec_bufptr = buf + len;
+ }
+ }
done:;
}
} else {
{
va_list args;
int result;
-
+
va_start(args, format);
result = CORD_vsprintf(out, format, args);
va_end(args);
va_list args;
int result;
CORD out;
-
+
va_start(args, format);
result = CORD_vsprintf(&out, format, args);
va_end(args);
{
int result;
CORD out;
-
+
result = CORD_vsprintf(&out, format, args);
if (result > 0) CORD_put(out, f);
return(result);
va_list args;
int result;
CORD out;
-
+
va_start(args, format);
result = CORD_vsprintf(&out, format, args);
va_end(args);
{
int result;
CORD out;
-
+
result = CORD_vsprintf(&out, format, args);
if (result > 0) CORD_put(out, stdout);
return(result);
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
- *
- * Author: Hans-J. Boehm (boehm@parc.xerox.com)
*/
+
/*
* These are functions on cords that do not need to understand their
* implementation. They serve also serve as example client code for
* cord_basics.
*/
-/* Boehm, December 8, 1995 1:53 pm PST */
+
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
- *
- * Author: Hans-J. Boehm (boehm@parc.xerox.com)
*/
+
/*
* A really simple-minded text editor based on cords.
* Things it does right:
- * No size bounds.
- * Inbounded undo.
- * Shouldn't crash no matter what file you invoke it on (e.g. /vmunix)
- * (Make sure /vmunix is not writable before you try this.)
- * Scrolls horizontally.
+ * No size bounds.
+ * Inbounded undo.
+ * Shouldn't crash no matter what file you invoke it on (e.g. /vmunix)
+ * (Make sure /vmunix is not writable before you try this.)
+ * Scrolls horizontally.
* Things it does wrong:
- * It doesn't handle tabs reasonably (use "expand" first).
- * The command set is MUCH too small.
- * The redisplay algorithm doesn't let curses do the scrolling.
- * The rule for moving the window over the file is suboptimal.
+ * It doesn't handle tabs reasonably (use "expand" first).
+ * The command set is MUCH too small.
+ * The redisplay algorithm doesn't let curses do the scrolling.
+ * The rule for moving the window over the file is suboptimal.
*/
-/* Boehm, February 6, 1995 12:27 pm PST */
-/* Boehm, May 19, 1994 2:20 pm PDT */
#include <stdio.h>
#include "gc.h"
#include "cord.h"
#endif
#if defined(__BORLANDC__) && !defined(WIN32)
- /* If this is DOS or win16, we'll fail anyway. */
- /* Might as well assume win32. */
+ /* If this is DOS or win16, we'll fail anyway. */
+ /* Might as well assume win32. */
# define WIN32
#endif
# include <windows.h>
# include "de_win.h"
#elif defined(MACINTOSH)
-# include <console.h>
+# include <console.h>
/* curses emulation. */
-# define initscr()
-# define endwin()
-# define nonl()
-# define noecho() csetmode(C_NOECHO, stdout)
-# define cbreak() csetmode(C_CBREAK, stdout)
-# define refresh()
-# define addch(c) putchar(c)
-# define standout() cinverse(1, stdout)
-# define standend() cinverse(0, stdout)
-# define move(line,col) cgotoxy(col + 1, line + 1, stdout)
-# define clrtoeol() ccleol(stdout)
-# define de_error(s) { fprintf(stderr, s); getchar(); }
-# define LINES 25
-# define COLS 80
+# define initscr()
+# define endwin()
+# define nonl()
+# define noecho() csetmode(C_NOECHO, stdout)
+# define cbreak() csetmode(C_CBREAK, stdout)
+# define refresh()
+# define addch(c) putchar(c)
+# define standout() cinverse(1, stdout)
+# define standend() cinverse(0, stdout)
+# define move(line,col) cgotoxy(col + 1, line + 1, stdout)
+# define clrtoeol() ccleol(stdout)
+# define de_error(s) { fprintf(stderr, s); getchar(); }
+# define LINES 25
+# define COLS 80
#else
# include <curses.h>
# define de_error(s) { fprintf(stderr, s); sleep(2); }
#include "de_cmds.h"
/* List of line number to position mappings, in descending order. */
-/* There may be holes. */
+/* There may be holes. */
typedef struct LineMapRep {
int line;
size_t pos;
typedef struct HistoryRep {
CORD file_contents;
struct HistoryRep * previous;
- line_map map; /* Invalid for first record "now" */
+ line_map map; /* Invalid for first record "now" */
} * history;
history now = 0;
-CORD current; /* == now -> file_contents. */
-size_t current_len; /* Current file length. */
-line_map current_map = 0; /* Current line no. to pos. map */
-size_t current_map_size = 0; /* Number of current_map entries. */
- /* Not always accurate, but reset */
- /* by prune_map. */
+CORD current; /* == now -> file_contents. */
+size_t current_len; /* Current file length. */
+line_map current_map = 0; /* Current line no. to pos. map */
+size_t current_map_size = 0; /* Number of current_map entries. */
+ /* Not always accurate, but reset */
+ /* by prune_map. */
# define MAX_MAP_SIZE 3000
/* Current display position */
# define ALL -1
# define NONE - 2
-int need_redisplay = 0; /* Line that needs to be redisplayed. */
+int need_redisplay = 0; /* Line that needs to be redisplayed. */
/* Current cursor position. Always within file. */
-int line = 0;
+int line = 0;
int col = 0;
-size_t file_pos = 0; /* Character position corresponding to cursor. */
+size_t file_pos = 0; /* Character position corresponding to cursor. */
/* Invalidate line map for lines > i */
void invalidate_map(int i)
}
/* Reduce the number of map entries to save space for huge files. */
-/* This also affects maps in histories. */
+/* This also affects maps in histories. */
void prune_map()
{
line_map map = current_map;
int start_line = map -> line;
-
+
current_map_size = 0;
for(; map != 0; map = map -> previous) {
- current_map_size++;
- if (map -> line < start_line - LINES && map -> previous != 0) {
- map -> previous = map -> previous -> previous;
- }
+ current_map_size++;
+ if (map -> line < start_line - LINES && map -> previous != 0) {
+ map -> previous = map -> previous -> previous;
+ }
}
}
/* Add mapping entry */
void add_map(int line, size_t pos)
{
line_map new_map = GC_NEW(struct LineMapRep);
-
+
if (current_map_size >= MAX_MAP_SIZE) prune_map();
new_map -> line = line;
new_map -> pos = pos;
/* Return position of column *c of ith line in */
/* current file. Adjust *c to be within the line.*/
-/* A 0 pointer is taken as 0 column. */
-/* Returns CORD_NOT_FOUND if i is too big. */
-/* Assumes i > dis_line. */
+/* A 0 pointer is taken as 0 column. */
+/* Returns CORD_NOT_FOUND if i is too big. */
+/* Assumes i > dis_line. */
size_t line_pos(int i, int *c)
{
int j;
size_t cur;
size_t next;
line_map map = current_map;
-
+
while (map -> line > i) map = map -> previous;
if (map -> line < i - 2) /* rebuild */ invalidate_map(i);
for (j = map -> line, cur = map -> pos; j < i;) {
- cur = CORD_chr(current, cur, '\n');
+ cur = CORD_chr(current, cur, '\n');
if (cur == current_len-1) return(CORD_NOT_FOUND);
cur++;
if (++j > current_map -> line) add_map(j, cur);
void add_hist(CORD s)
{
history new_file = GC_NEW(struct HistoryRep);
-
+
new_file -> file_contents = current = s;
current_len = CORD_len(s);
new_file -> previous = now;
current_len = CORD_len(current);
}
-/* Current screen_contents; a dynamically allocated array of CORDs */
+/* Current screen_contents; a dynamically allocated array of CORDs */
CORD * screen = 0;
int screen_size = 0;
# ifndef WIN32
-/* Replace a line in the curses stdscr. All control characters are */
-/* displayed as upper case characters in standout mode. This isn't */
-/* terribly appropriate for tabs. */
+/* Replace a line in the curses stdscr. All control characters are */
+/* displayed as upper case characters in standout mode. This isn't */
+/* terribly appropriate for tabs. */
void replace_line(int i, CORD s)
{
register int c;
CORD_pos p;
size_t len = CORD_len(s);
-
+
if (screen == 0 || LINES > screen_size) {
screen_size = LINES;
- screen = (CORD *)GC_MALLOC(screen_size * sizeof(CORD));
+ screen = (CORD *)GC_MALLOC(screen_size * sizeof(CORD));
}
# if !defined(MACINTOSH)
/* A gross workaround for an apparent curses bug: */
CORD_FOR (p, s) {
c = CORD_pos_fetch(p) & 0x7f;
if (iscntrl(c)) {
- standout(); addch(c + 0x40); standend();
+ standout(); addch(c + 0x40); standend();
} else {
- addch(c);
- }
- }
- screen[i] = s;
+ addch(c);
+ }
+ }
+ screen[i] = s;
}
}
#else
# define replace_line(i,s) invalidate_line(i)
#endif
-/* Return up to COLS characters of the line of s starting at pos, */
-/* returning only characters after the given column. */
+/* Return up to COLS characters of the line of s starting at pos, */
+/* returning only characters after the given column. */
CORD retrieve_line(CORD s, size_t pos, unsigned column)
{
CORD candidate = CORD_substr(s, pos, column + COLS);
- /* avoids scanning very long lines */
+ /* avoids scanning very long lines */
int eol = CORD_chr(candidate, 0, '\n');
int len;
-
+
if (eol == CORD_NOT_FOUND) eol = CORD_len(candidate);
len = (int)eol - (int)column;
if (len < 0) len = 0;
CORD retrieve_screen_line(int i)
{
- register size_t pos;
-
- invalidate_map(dis_line + LINES); /* Prune search */
- pos = line_pos(dis_line + i, 0);
- if (pos == CORD_NOT_FOUND) return(CORD_EMPTY);
- return(retrieve_line(current, pos, dis_col));
+ register size_t pos;
+
+ invalidate_map(dis_line + LINES); /* Prune search */
+ pos = line_pos(dis_line + i, 0);
+ if (pos == CORD_NOT_FOUND) return(CORD_EMPTY);
+ return(retrieve_line(current, pos, dis_col));
}
# endif
-/* Display the visible section of the current file */
+/* Display the visible section of the current file */
void redisplay(void)
{
register int i;
-
- invalidate_map(dis_line + LINES); /* Prune search */
+
+ invalidate_map(dis_line + LINES); /* Prune search */
for (i = 0; i < LINES; i++) {
if (need_redisplay == ALL || need_redisplay == i) {
register size_t pos = line_pos(dis_line + i, 0);
-
+
if (pos == CORD_NOT_FOUND) break;
replace_line(i, retrieve_line(current, pos, dis_col));
if (need_redisplay == i) goto done;
int dis_granularity;
-/* Update dis_line, dis_col, and dis_pos to make cursor visible. */
-/* Assumes line, col, dis_line, dis_pos are in bounds. */
+/* Update dis_line, dis_col, and dis_pos to make cursor visible. */
+/* Assumes line, col, dis_line, dis_pos are in bounds. */
void normalize_display()
{
int old_line = dis_line;
int old_col = dis_col;
-
+
dis_granularity = 1;
if (LINES > 15 && COLS > 15) dis_granularity = 2;
while (dis_line > line) dis_line -= dis_granularity;
# if defined(WIN32)
# elif defined(MACINTOSH)
-# define move_cursor(x,y) cgotoxy(x + 1, y + 1, stdout)
+# define move_cursor(x,y) cgotoxy(x + 1, y + 1, stdout)
# else
-# define move_cursor(x,y) move(y,x)
+# define move_cursor(x,y) move(y,x)
# endif
-/* Adjust display so that cursor is visible; move cursor into position */
-/* Update screen if necessary. */
+/* Adjust display so that cursor is visible; move cursor into position */
+/* Update screen if necessary. */
void fix_cursor(void)
{
normalize_display();
# endif
}
-/* Make sure line, col, and dis_pos are somewhere inside file. */
-/* Recompute file_pos. Assumes dis_pos is accurate or past eof */
+/* Make sure line, col, and dis_pos are somewhere inside file. */
+/* Recompute file_pos. Assumes dis_pos is accurate or past eof */
void fix_pos()
{
int my_col = col;
-
+
if ((size_t)line > current_len) line = current_len;
file_pos = line_pos(line, &my_col);
if (file_pos == CORD_NOT_FOUND) {
for (line = current_map -> line, file_pos = current_map -> pos;
file_pos < current_len;
line++, file_pos = CORD_chr(current, file_pos, '\n') + 1);
- line--;
+ line--;
file_pos = line_pos(line, &col);
} else {
- col = my_col;
+ col = my_col;
}
}
#if defined(WIN32)
-# define beep() Beep(1000 /* Hz */, 300 /* msecs */)
+# define beep() Beep(1000 /* Hz */, 300 /* msecs */)
#elif defined(MACINTOSH)
-# define beep() SysBeep(1)
+# define beep() SysBeep(1)
#else
/*
* beep() is part of some curses packages and not others.
# define NO_PREFIX -1
# define BARE_PREFIX -2
-int repeat_count = NO_PREFIX; /* Current command prefix. */
+int repeat_count = NO_PREFIX; /* Current command prefix. */
-int locate_mode = 0; /* Currently between 2 ^Ls */
-CORD locate_string = CORD_EMPTY; /* Current search string. */
+int locate_mode = 0; /* Currently between 2 ^Ls */
+CORD locate_string = CORD_EMPTY; /* Current search string. */
char * arg_file_name;
#ifdef WIN32
-/* Change the current position to whatever is currently displayed at */
-/* the given SCREEN coordinates. */
+/* Change the current position to whatever is currently displayed at */
+/* the given SCREEN coordinates. */
void set_position(int c, int l)
{
line = l + dis_line;
}
#endif /* WIN32 */
-/* Perform the command associated with character c. C may be an */
-/* integer > 256 denoting a windows command, one of the above control */
-/* characters, or another ASCII character to be used as either a */
-/* character to be inserted, a repeat count, or a search string, */
-/* depending on the current state. */
+/* Perform the command associated with character c. C may be an */
+/* integer > 256 denoting a windows command, one of the above control */
+/* characters, or another ASCII character to be used as either a */
+/* character to be inserted, a repeat count, or a search string, */
+/* depending on the current state. */
void do_command(int c)
{
int i;
int need_fix_pos;
FILE * out;
-
+
if ( c == '\r') c = '\n';
if (locate_mode) {
size_t new_pos;
-
+
if (c == LOCATE) {
locate_mode = 0;
locate_string = CORD_EMPTY;
}
locate_string = CORD_cat_char(locate_string, (char)c);
new_pos = CORD_str(current, file_pos - CORD_len(locate_string) + 1,
- locate_string);
+ locate_string);
if (new_pos != CORD_NOT_FOUND) {
need_redisplay = ALL;
new_pos += CORD_len(locate_string);
for (;;) {
- file_pos = line_pos(line + 1, 0);
- if (file_pos > new_pos) break;
- line++;
+ file_pos = line_pos(line + 1, 0);
+ if (file_pos > new_pos) break;
+ line++;
}
col = new_pos - line_pos(line, 0);
file_pos = new_pos;
fix_cursor();
} else {
locate_string = CORD_substr(locate_string, 0,
- CORD_len(locate_string) - 1);
+ CORD_len(locate_string) - 1);
beep();
}
return;
}
if (c == REPEAT) {
- repeat_count = BARE_PREFIX; return;
+ repeat_count = BARE_PREFIX; return;
} else if (c < 0x100 && isdigit(c)){
if (repeat_count == BARE_PREFIX) {
repeat_count = c - '0'; return;
}
if (repeat_count == NO_PREFIX) repeat_count = 1;
if (repeat_count == BARE_PREFIX && (c == UP || c == DOWN)) {
- repeat_count = LINES - dis_granularity;
+ repeat_count = LINES - dis_granularity;
}
if (repeat_count == BARE_PREFIX) repeat_count = 8;
need_fix_pos = 0;
case TOP:
line = col = file_pos = 0;
break;
- case UP:
- if (line != 0) {
- line--;
- need_fix_pos = 1;
- }
- break;
- case DOWN:
- line++;
- need_fix_pos = 1;
- break;
- case LEFT:
- if (col != 0) {
- col--; file_pos--;
- }
- break;
- case RIGHT:
- if (CORD_fetch(current, file_pos) == '\n') break;
- col++; file_pos++;
- break;
- case UNDO:
- del_hist();
- need_redisplay = ALL; need_fix_pos = 1;
- break;
- case BS:
- if (col == 0) {
- beep();
- break;
- }
- col--; file_pos--;
- /* fall through: */
- case DEL:
- if (file_pos == current_len-1) break;
- /* Can't delete trailing newline */
- if (CORD_fetch(current, file_pos) == '\n') {
- need_redisplay = ALL; need_fix_pos = 1;
- } else {
- need_redisplay = line - dis_line;
- }
- add_hist(CORD_cat(
- CORD_substr(current, 0, file_pos),
- CORD_substr(current, file_pos+1, current_len)));
- invalidate_map(line);
- break;
- case WRITE:
- {
- CORD name = CORD_cat(CORD_from_char_star(arg_file_name),
- ".new");
-
- if ((out = fopen(CORD_to_const_char_star(name), "wb")) == NULL
- || CORD_put(current, out) == EOF) {
- de_error("Write failed\n");
- need_redisplay = ALL;
+ case UP:
+ if (line != 0) {
+ line--;
+ need_fix_pos = 1;
+ }
+ break;
+ case DOWN:
+ line++;
+ need_fix_pos = 1;
+ break;
+ case LEFT:
+ if (col != 0) {
+ col--; file_pos--;
+ }
+ break;
+ case RIGHT:
+ if (CORD_fetch(current, file_pos) == '\n') break;
+ col++; file_pos++;
+ break;
+ case UNDO:
+ del_hist();
+ need_redisplay = ALL; need_fix_pos = 1;
+ break;
+ case BS:
+ if (col == 0) {
+ beep();
+ break;
+ }
+ col--; file_pos--;
+ /* fall through: */
+ case DEL:
+ if (file_pos == current_len-1) break;
+ /* Can't delete trailing newline */
+ if (CORD_fetch(current, file_pos) == '\n') {
+ need_redisplay = ALL; need_fix_pos = 1;
+ } else {
+ need_redisplay = line - dis_line;
+ }
+ add_hist(CORD_cat(
+ CORD_substr(current, 0, file_pos),
+ CORD_substr(current, file_pos+1, current_len)));
+ invalidate_map(line);
+ break;
+ case WRITE:
+ {
+ CORD name = CORD_cat(CORD_from_char_star(arg_file_name),
+ ".new");
+
+ if ((out = fopen(CORD_to_const_char_star(name), "wb")) == NULL
+ || CORD_put(current, out) == EOF) {
+ de_error("Write failed\n");
+ need_redisplay = ALL;
} else {
fclose(out);
}
- }
+ }
break;
- default:
- {
- CORD left_part = CORD_substr(current, 0, file_pos);
- CORD right_part = CORD_substr(current, file_pos, current_len);
-
- add_hist(CORD_cat(CORD_cat_char(left_part, (char)c),
- right_part));
- invalidate_map(line);
- if (c == '\n') {
- col = 0; line++; file_pos++;
- need_redisplay = ALL;
- } else {
- col++; file_pos++;
- need_redisplay = line - dis_line;
- }
- break;
- }
+ default:
+ {
+ CORD left_part = CORD_substr(current, 0, file_pos);
+ CORD right_part = CORD_substr(current, file_pos, current_len);
+
+ add_hist(CORD_cat(CORD_cat_char(left_part, (char)c),
+ right_part));
+ invalidate_map(line);
+ if (c == '\n') {
+ col = 0; line++; file_pos++;
+ need_redisplay = ALL;
+ } else {
+ col++; file_pos++;
+ need_redisplay = line - dis_line;
+ }
+ break;
+ }
}
}
if (need_fix_pos) fix_pos();
{
FILE * f;
CORD initial;
-
+
if ((f = fopen(arg_file_name, "rb")) == NULL) {
- initial = "\n";
+ initial = "\n";
} else {
initial = CORD_from_file(f);
if (initial == CORD_EMPTY
int c;
#if defined(MACINTOSH)
- console_options.title = "\pDumb Editor";
- cshow(stdout);
- argc = ccommand(&argv);
+ console_options.title = "\pDumb Editor";
+ cshow(stdout);
+ argc = ccommand(&argv);
#endif
GC_INIT();
-
+
if (argc != 2) goto usage;
arg_file_name = argv[1];
setvbuf(stdout, GC_MALLOC_ATOMIC(8192), _IOFBF, 8192);
noecho(); nonl(); cbreak();
generic_init();
while ((c = getchar()) != QUIT) {
- if (c == EOF) break;
- do_command(c);
+ if (c == EOF) break;
+ do_command(c);
}
done:
move(LINES-1, 0);
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, May 19, 1994 2:24 pm PDT */
#ifndef DE_CMDS_H
# define DE_CMDS_H
-# define UP 16 /* ^P */
-# define DOWN 14 /* ^N */
-# define LEFT 2 /* ^B */
-# define RIGHT 6 /* ^F */
-# define DEL 127 /* ^? */
-# define BS 8 /* ^H */
-# define UNDO 21 /* ^U */
-# define WRITE 23 /* ^W */
-# define QUIT 4 /* ^D */
-# define REPEAT 18 /* ^R */
-# define LOCATE 12 /* ^L */
-# define TOP 20 /* ^T */
+# define UP 16 /* ^P */
+# define DOWN 14 /* ^N */
+# define LEFT 2 /* ^B */
+# define RIGHT 6 /* ^F */
+# define DEL 127 /* ^? */
+# define BS 8 /* ^H */
+# define UNDO 21 /* ^U */
+# define WRITE 23 /* ^W */
+# define QUIT 4 /* ^D */
+# define REPEAT 18 /* ^R */
+# define LOCATE 12 /* ^L */
+# define TOP 20 /* ^T */
#endif
-
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, February 6, 1995 12:29 pm PST */
/*
- * The MS Windows specific part of de.
+ * The MS Windows specific part of de.
* This started as the generic Windows application template
- * made available by Rob Haack (rhaack@polaris.unm.edu), but
- * significant parts didn't survive to the final version.
+ * but significant parts didn't survive to the final version.
*
* This was written by a nonexpert windows programmer.
*/
-
#include "windows.h"
#include "gc.h"
#include "cord.h"
HANDLE hAccel;
# ifdef THREAD_LOCAL_ALLOC
- GC_INIT(); /* Required if GC is built with THREAD_LOCAL_ALLOC */
- /* Always safe, but this is used as a GC test. */
+ GC_INIT(); /* Required if GC is built with THREAD_LOCAL_ALLOC */
+ /* Always safe, but this is used as a GC test. */
# endif
if (!hPrevInstance)
if (RegisterClass (&wndclass) == 0) {
char buf[50];
-
- sprintf(buf, "RegisterClass: error code: 0x%X", GetLastError());
- de_error(buf);
- return(0);
+
+ sprintf(buf, "RegisterClass: error code: 0x%X", GetLastError());
+ de_error(buf);
+ return(0);
}
}
-
+
/* Empirically, the command line does not include the command name ...
if (command_line != 0) {
while (isspace(*command_line)) command_line++;
while (*command_line != 0 && !isspace(*command_line)) command_line++;
while (isspace(*command_line)) command_line++;
} */
-
+
if (command_line == 0 || *command_line == 0) {
de_error("File name argument required");
return( 0 );
} else {
char *p = command_line;
-
+
while (*p != 0 && !isspace(*p)) p++;
- arg_file_name = CORD_to_char_star(
- CORD_substr(command_line, 0, p - command_line));
+ arg_file_name = CORD_to_char_star(
+ CORD_substr(command_line, 0, p - command_line));
}
hwnd = CreateWindow (szAppName,
- FullAppName,
- WS_OVERLAPPEDWINDOW | WS_CAPTION, /* Window style */
- CW_USEDEFAULT, 0, /* default pos. */
- CW_USEDEFAULT, 0, /* default width, height */
- NULL, /* No parent */
- NULL, /* Window class menu */
- hInstance, NULL);
+ FullAppName,
+ WS_OVERLAPPEDWINDOW | WS_CAPTION, /* Window style */
+ CW_USEDEFAULT, 0, /* default pos. */
+ CW_USEDEFAULT, 0, /* default width, height */
+ NULL, /* No parent */
+ NULL, /* Window class menu */
+ hInstance, NULL);
if (hwnd == NULL) {
- char buf[50];
-
- sprintf(buf, "CreateWindow: error code: 0x%X", GetLastError());
- de_error(buf);
- return(0);
+ char buf[50];
+
+ sprintf(buf, "CreateWindow: error code: 0x%X", GetLastError());
+ de_error(buf);
+ return(0);
}
ShowWindow (hwnd, nCmdShow);
hAccel = LoadAccelerators( hInstance, szAppName );
-
+
while (GetMessage (&msg, NULL, 0, 0))
{
if( !TranslateAccelerator( hwnd, hAccel, &msg ) )
return msg.wParam;
}
-/* Return the argument with all control characters replaced by blanks. */
+/* Return the argument with all control characters replaced by blanks. */
char * plain_chars(char * text, size_t len)
{
char * result = GC_MALLOC_ATOMIC(len + 1);
register size_t i;
-
+
for (i = 0; i < len; i++) {
if (iscntrl(text[i])) {
result[i] = ' ';
return(result);
}
-/* Return the argument with all non-control-characters replaced by */
-/* blank, and all control characters c replaced by c + 32. */
+/* Return the argument with all non-control-characters replaced by */
+/* blank, and all control characters c replaced by c + 32. */
char * control_chars(char * text, size_t len)
{
char * result = GC_MALLOC_ATOMIC(len + 1);
register size_t i;
-
+
for (i = 0; i < len; i++) {
if (iscntrl(text[i])) {
result[i] = text[i] + 0x40;
rectp -> right = win_width;
}
-int caret_visible = 0; /* Caret is currently visible. */
+int caret_visible = 0; /* Caret is currently visible. */
-int screen_was_painted = 0;/* Screen has been painted at least once. */
+int screen_was_painted = 0;/* Screen has been painted at least once. */
void update_cursor(void);
char_width = tm.tmAveCharWidth;
char_height = tm.tmHeight + tm.tmExternalLeading;
GetClientRect(hwnd, &client_area);
- COLS = (client_area.right - client_area.left)/char_width;
- LINES = (client_area.bottom - client_area.top)/char_height;
- generic_init();
+ COLS = (client_area.right - client_area.left)/char_width;
+ LINES = (client_area.bottom - client_area.top)/char_height;
+ generic_init();
return(0);
case WM_CHAR:
- if (wParam == QUIT) {
- SendMessage( hwnd, WM_CLOSE, 0, 0L );
- } else {
- do_command((int)wParam);
- }
- return(0);
-
+ if (wParam == QUIT) {
+ SendMessage( hwnd, WM_CLOSE, 0, 0L );
+ } else {
+ do_command((int)wParam);
+ }
+ return(0);
+
case WM_SETFOCUS:
- CreateCaret(hwnd, NULL, char_width, char_height);
- ShowCaret(hwnd);
- caret_visible = 1;
- update_cursor();
- return(0);
-
+ CreateCaret(hwnd, NULL, char_width, char_height);
+ ShowCaret(hwnd);
+ caret_visible = 1;
+ update_cursor();
+ return(0);
+
case WM_KILLFOCUS:
- HideCaret(hwnd);
- DestroyCaret();
- caret_visible = 0;
- return(0);
-
+ HideCaret(hwnd);
+ DestroyCaret();
+ caret_visible = 0;
+ return(0);
+
case WM_LBUTTONUP:
- {
- unsigned xpos = LOWORD(lParam); /* From left */
- unsigned ypos = HIWORD(lParam); /* from top */
-
- set_position( xpos/char_width, ypos/char_height );
- return(0);
- }
-
+ {
+ unsigned xpos = LOWORD(lParam); /* From left */
+ unsigned ypos = HIWORD(lParam); /* from top */
+
+ set_position( xpos/char_width, ypos/char_height );
+ return(0);
+ }
+
case WM_COMMAND:
- id = LOWORD(wParam);
- if (id & EDIT_CMD_FLAG) {
+ id = LOWORD(wParam);
+ if (id & EDIT_CMD_FLAG) {
if (id & REPEAT_FLAG) do_command(REPEAT);
do_command(CHAR_CMD(id));
return( 0 );
hwnd, AboutBoxCallback ) )
InvalidateRect( hwnd, NULL, TRUE );
return( 0 );
- case IDM_HELPCONTENTS:
- de_error(
- "Cursor keys: ^B(left) ^F(right) ^P(up) ^N(down)\n"
- "Undo: ^U Write: ^W Quit:^D Repeat count: ^R[n]\n"
- "Top: ^T Locate (search, find): ^L text ^L\n");
- return( 0 );
- }
- }
+ case IDM_HELPCONTENTS:
+ de_error(
+ "Cursor keys: ^B(left) ^F(right) ^P(up) ^N(down)\n"
+ "Undo: ^U Write: ^W Quit:^D Repeat count: ^R[n]\n"
+ "Top: ^T Locate (search, find): ^L text ^L\n");
+ return( 0 );
+ }
+ }
break;
case WM_CLOSE:
case WM_DESTROY:
PostQuitMessage (0);
- GC_win32_free_heap();
+ GC_win32_free_heap();
return 0;
-
+
case WM_PAINT:
- dc = BeginPaint(hwnd, &ps);
- GetClientRect(hwnd, &client_area);
- COLS = (client_area.right - client_area.left)/char_width;
- LINES = (client_area.bottom - client_area.top)/char_height;
- SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT));
- for (i = 0; i < LINES; i++) {
- get_line_rect(i, client_area.right, &this_line);
- if (IntersectRect(&dummy, &this_line, &ps.rcPaint)) {
- CORD raw_line = retrieve_screen_line(i);
- size_t len = CORD_len(raw_line);
- char * text = CORD_to_char_star(raw_line);
- /* May contain embedded NULLs */
- char * plain = plain_chars(text, len);
- char * blanks = CORD_to_char_star(CORD_chars(' ',
- COLS - len));
- char * control = control_chars(text, len);
-# define RED RGB(255,0,0)
-
- SetBkMode(dc, OPAQUE);
- SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
-
- TextOut(dc, this_line.left, this_line.top,
- plain, (int)len);
- TextOut(dc, this_line.left + (int)len * char_width,
- this_line.top,
- blanks, (int)(COLS - len));
- SetBkMode(dc, TRANSPARENT);
- SetTextColor(dc, RED);
- TextOut(dc, this_line.left, this_line.top,
- control, (int)strlen(control));
- }
- }
- EndPaint(hwnd, &ps);
- screen_was_painted = 1;
- return 0;
+ dc = BeginPaint(hwnd, &ps);
+ GetClientRect(hwnd, &client_area);
+ COLS = (client_area.right - client_area.left)/char_width;
+ LINES = (client_area.bottom - client_area.top)/char_height;
+ SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT));
+ for (i = 0; i < LINES; i++) {
+ get_line_rect(i, client_area.right, &this_line);
+ if (IntersectRect(&dummy, &this_line, &ps.rcPaint)) {
+ CORD raw_line = retrieve_screen_line(i);
+ size_t len = CORD_len(raw_line);
+ char * text = CORD_to_char_star(raw_line);
+ /* May contain embedded NULLs */
+ char * plain = plain_chars(text, len);
+ char * blanks = CORD_to_char_star(CORD_chars(' ',
+ COLS - len));
+ char * control = control_chars(text, len);
+# define RED RGB(255,0,0)
+
+ SetBkMode(dc, OPAQUE);
+ SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
+
+ TextOut(dc, this_line.left, this_line.top,
+ plain, (int)len);
+ TextOut(dc, this_line.left + (int)len * char_width,
+ this_line.top,
+ blanks, (int)(COLS - len));
+ SetBkMode(dc, TRANSPARENT);
+ SetTextColor(dc, RED);
+ TextOut(dc, this_line.left, this_line.top,
+ control, (int)strlen(control));
+ }
+ }
+ EndPaint(hwnd, &ps);
+ screen_was_painted = 1;
+ return 0;
}
return DefWindowProc (hwnd, message, wParam, lParam);
}
{
last_col = c;
last_line = l;
-
+
if (caret_visible) update_cursor();
}
void invalidate_line(int i)
{
RECT line;
-
+
if (!screen_was_painted) return;
- /* Invalidating a rectangle before painting seems result in a */
- /* major performance problem. */
+ /* Invalidating a rectangle before painting seems result in a */
+ /* major performance problem. */
get_line_rect(i, COLS*char_width, &line);
InvalidateRect(hwnd, &line, FALSE);
}
-
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, May 19, 1994 2:25 pm PDT */
/* cord.h, de_cmds.h, and windows.h should be included before this. */
-
-# define OTHER_FLAG 0x100
-# define EDIT_CMD_FLAG 0x200
-# define REPEAT_FLAG 0x400
+# define OTHER_FLAG 0x100
+# define EDIT_CMD_FLAG 0x200
+# define REPEAT_FLAG 0x400
# define CHAR_CMD(i) ((i) & 0xff)
/* MENU: DE */
-#define IDM_FILESAVE (EDIT_CMD_FLAG + WRITE)
-#define IDM_FILEEXIT (OTHER_FLAG + 1)
-#define IDM_HELPABOUT (OTHER_FLAG + 2)
-#define IDM_HELPCONTENTS (OTHER_FLAG + 3)
+#define IDM_FILESAVE (EDIT_CMD_FLAG + WRITE)
+#define IDM_FILEEXIT (OTHER_FLAG + 1)
+#define IDM_HELPABOUT (OTHER_FLAG + 2)
+#define IDM_HELPCONTENTS (OTHER_FLAG + 3)
-#define IDM_EDITPDOWN (REPEAT_FLAG + EDIT_CMD_FLAG + DOWN)
-#define IDM_EDITPUP (REPEAT_FLAG + EDIT_CMD_FLAG + UP)
-#define IDM_EDITUNDO (EDIT_CMD_FLAG + UNDO)
-#define IDM_EDITLOCATE (EDIT_CMD_FLAG + LOCATE)
-#define IDM_EDITDOWN (EDIT_CMD_FLAG + DOWN)
-#define IDM_EDITUP (EDIT_CMD_FLAG + UP)
-#define IDM_EDITLEFT (EDIT_CMD_FLAG + LEFT)
-#define IDM_EDITRIGHT (EDIT_CMD_FLAG + RIGHT)
-#define IDM_EDITBS (EDIT_CMD_FLAG + BS)
-#define IDM_EDITDEL (EDIT_CMD_FLAG + DEL)
-#define IDM_EDITREPEAT (EDIT_CMD_FLAG + REPEAT)
-#define IDM_EDITTOP (EDIT_CMD_FLAG + TOP)
+#define IDM_EDITPDOWN (REPEAT_FLAG + EDIT_CMD_FLAG + DOWN)
+#define IDM_EDITPUP (REPEAT_FLAG + EDIT_CMD_FLAG + UP)
+#define IDM_EDITUNDO (EDIT_CMD_FLAG + UNDO)
+#define IDM_EDITLOCATE (EDIT_CMD_FLAG + LOCATE)
+#define IDM_EDITDOWN (EDIT_CMD_FLAG + DOWN)
+#define IDM_EDITUP (EDIT_CMD_FLAG + UP)
+#define IDM_EDITLEFT (EDIT_CMD_FLAG + LEFT)
+#define IDM_EDITRIGHT (EDIT_CMD_FLAG + RIGHT)
+#define IDM_EDITBS (EDIT_CMD_FLAG + BS)
+#define IDM_EDITDEL (EDIT_CMD_FLAG + DEL)
+#define IDM_EDITREPEAT (EDIT_CMD_FLAG + REPEAT)
+#define IDM_EDITTOP (EDIT_CMD_FLAG + TOP)
-/* Windows UI stuff */
+/* Windows UI stuff */
LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
- UINT wParam, LONG lParam);
+ UINT wParam, LONG lParam);
LRESULT CALLBACK AboutBox( HWND hDlg, UINT message,
- UINT wParam, LONG lParam );
+ UINT wParam, LONG lParam );
-/* Screen dimensions. Maintained by de_win.c. */
+/* Screen dimensions. Maintained by de_win.c. */
extern int LINES;
extern int COLS;
-/* File being edited. */
+/* File being edited. */
extern char * arg_file_name;
-/* Current display position in file. Maintained by de.c */
+/* Current display position in file. Maintained by de.c */
extern int dis_line;
extern int dis_col;
-/* Current cursor position in file. */
+/* Current cursor position in file. */
extern int line;
extern int col;
/*
* Calls from de_win.c to de.c
*/
-
+
CORD retrieve_screen_line(int i);
- /* Get the contents of i'th screen line. */
- /* Relies on COLS. */
+ /* Get the contents of i'th screen line. */
+ /* Relies on COLS. */
void set_position(int x, int y);
- /* Set column, row. Upper left of window = (0,0). */
+ /* Set column, row. Upper left of window = (0,0). */
void do_command(int);
- /* Execute an editor command. */
- /* Agument is a command character or one */
- /* of the IDM_ commands. */
+ /* Execute an editor command. */
+ /* Agument is a command character or one */
+ /* of the IDM_ commands. */
void generic_init(void);
- /* OS independent initialization */
+ /* OS independent initialization */
/*
* Calls from de.c to de_win.c
*/
-
+
void move_cursor(int column, int line);
- /* Physically move the cursor on the display, */
- /* so that it appears at */
- /* (column, line). */
+ /* Physically move the cursor on the display, */
+ /* so that it appears at */
+ /* (column, line). */
void invalidate_line(int line);
- /* Invalidate line i on the screen. */
+ /* Invalidate line i on the screen. */
void de_error(char *s);
- /* Display error message. */
\ No newline at end of file
+ /* Display error message. */
-- Margaret
-The badge4 has a StrongArm-1110 processor and a StrongArm-1111 coprocessor.
+The badge4 has a StrongArm-1110 processor and a StrongArm-1111 coprocessor.
Assume that the garbage collector distribution is unpacked into /home/arm/gc6.0,
which is visible to both the ARM machine and a linux desktop (e.g. via NFS mounting).
On your desktop, do:
make
make install
-The main garbage collector library should now be in ../gc6.0/lib/libgc.so.
+The main garbage collector library should now be in ../gc6.0/lib/libgc.so.
To test the garbage collector, first do the following on your desktop
make gctest
-------------------------------
# config.site for configure
-# Modified from the one provided by Bradley D. LaRonde
-# Edited by Andrej Cedilnik <acedil1@csee.umbc.edu>
-# Used some of solutions by Tilman Vogel <Tilman.Vogel@web.de>
-# Ported for iPAQ Familiar by Oliver Kurth <oliver.kurth@innominate.com>
-# Further modified by Margaret Fleck for the badge4
-
HOSTCC=gcc
# Names of the cross-compilers
# Permission to modify the code and to distribute modified code is granted,
# provided the above notices are retained, and a notice that the code was
# modified is included with the above copyright notice.
-#
-# Modified by: Grzegorz Jakacki <jakacki at acm dot org>
-# Modified by: Petter Urkedal <petter.urkedal@nordita.dk>
## Process this file with automake to produce Makefile.in.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
- *
- * Original author: Bill Janssen
- * Heavily modified by Hans Boehm and others
*/
#include "private/gc_priv.h"
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
*
- * Last modified on Sat Nov 19 19:31:14 PST 1994 by ellis
- *
* Permission is hereby granted to copy this code for any purpose,
* provided the above notices are retained on all copies.
*/
You should ensure (using implementation-dependent techniques) that the
linker finds this module before the library that defines the default
built-in "new" and "delete".
-
-Authors: John R. Ellis and Jesse Hull
-
**************************************************************************/
# ifdef HAVE_CONFIG_H
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
- *
- * Original author: Bill Janssen
- * Heavily modified by Hans Boehm and others
*/
#include "private/gc_priv.h"
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
- *
- * Author: Hans-J. Boehm (boehm@parc.xerox.com)
*/
/*
-#
-#
+#
# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
# OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
-#
+#
# Permission is hereby granted to use or copy this program
# for any purpose, provided the above notices are retained on all copies.
# Permission to modify the code and to distribute modified code is granted,
# provided the above notices are retained, and a notice that the code was
# modified is included with the above copyright notice.
-#
-# Modified by: Grzegorz Jakacki <jakacki at acm dot org>
-# Modified by: Petter Urkedal <petter.urkedal@nordita.dk>
## Process this file with automake to produce part of Makefile.in.
include/private/thread_local_alloc.h \
include/cord.h \
include/ec.h \
- include/javaxfc.h
+ include/javaxfc.h
# unprefixed header
include_HEADERS += \
-/*
+/*
* Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, May 19, 1994 2:23 pm PDT */
+
# ifndef CORD_POSITION_H
-/* The representation of CORD_position. This is private to the */
-/* implementation, but the size is known to clients. Also */
-/* the implementation of some exported macros relies on it. */
-/* Don't use anything defined here and not in cord.h. */
+/* The representation of CORD_position. This is private to the */
+/* implementation, but the size is known to clients. Also */
+/* the implementation of some exported macros relies on it. */
+/* Don't use anything defined here and not in cord.h. */
# define MAX_DEPTH 48
- /* The maximum depth of a balanced cord + 1. */
- /* We don't let cords get deeper than MAX_DEPTH. */
+ /* The maximum depth of a balanced cord + 1. */
+ /* We don't let cords get deeper than MAX_DEPTH. */
struct CORD_pe {
CORD pe_cord;
size_t pe_start_pos;
};
-/* A structure describing an entry on the path from the root */
-/* to current position. */
+/* A structure describing an entry on the path from the root */
+/* to current position. */
typedef struct CORD_Pos {
size_t cur_pos;
int path_len;
-# define CORD_POS_INVALID (0x55555555)
- /* path_len == INVALID <==> position invalid */
- const char *cur_leaf; /* Current leaf, if it is a string. */
- /* If the current leaf is a function, */
- /* then this may point to function_buf */
- /* containing the next few characters. */
- /* Always points to a valid string */
- /* containing the current character */
- /* unless cur_end is 0. */
- size_t cur_start; /* Start position of cur_leaf */
- size_t cur_end; /* Ending position of cur_leaf */
- /* 0 if cur_leaf is invalid. */
+# define CORD_POS_INVALID (0x55555555)
+ /* path_len == INVALID <==> position invalid */
+ const char *cur_leaf; /* Current leaf, if it is a string. */
+ /* If the current leaf is a function, */
+ /* then this may point to function_buf */
+ /* containing the next few characters. */
+ /* Always points to a valid string */
+ /* containing the current character */
+ /* unless cur_end is 0. */
+ size_t cur_start; /* Start position of cur_leaf */
+ size_t cur_end; /* Ending position of cur_leaf */
+ /* 0 if cur_leaf is invalid. */
struct CORD_pe path[MAX_DEPTH + 1];
- /* path[path_len] is the leaf corresponding to cur_pos */
- /* path[0].pe_cord is the cord we point to. */
+ /* path[path_len] is the leaf corresponding to cur_pos */
+ /* path[0].pe_cord is the cord we point to. */
# define FUNCTION_BUF_SZ 8
- char function_buf[FUNCTION_BUF_SZ]; /* Space for next few chars */
- /* from function node. */
+ char function_buf[FUNCTION_BUF_SZ]; /* Space for next few chars */
+ /* from function node. */
} CORD_pos[1];
-/* Extract the cord from a position: */
+/* Extract the cord from a position: */
CORD CORD_pos_to_cord(CORD_pos p);
-
-/* Extract the current index from a position: */
+
+/* Extract the current index from a position: */
size_t CORD_pos_to_index(CORD_pos p);
-
-/* Fetch the character located at the given position: */
+
+/* Fetch the character located at the given position: */
char CORD_pos_fetch(CORD_pos p);
-
-/* Initialize the position to refer to the give cord and index. */
-/* Note that this is the most expensive function on positions: */
+
+/* Initialize the position to refer to the give cord and index. */
+/* Note that this is the most expensive function on positions: */
void CORD_set_pos(CORD_pos p, CORD x, size_t i);
-
-/* Advance the position to the next character. */
-/* P must be initialized and valid. */
-/* Invalidates p if past end: */
+
+/* Advance the position to the next character. */
+/* P must be initialized and valid. */
+/* Invalidates p if past end: */
void CORD_next(CORD_pos p);
-/* Move the position to the preceding character. */
-/* P must be initialized and valid. */
-/* Invalidates p if past beginning: */
+/* Move the position to the preceding character. */
+/* P must be initialized and valid. */
+/* Invalidates p if past beginning: */
void CORD_prev(CORD_pos p);
-
-/* Is the position valid, i.e. inside the cord? */
+
+/* Is the position valid, i.e. inside the cord? */
int CORD_pos_valid(CORD_pos p);
char CORD__pos_fetch(CORD_pos);
void CORD__next(CORD_pos);
void CORD__prev(CORD_pos);
-#define CORD_pos_fetch(p) \
+#define CORD_pos_fetch(p) \
(((p)[0].cur_end != 0)? \
- (p)[0].cur_leaf[(p)[0].cur_pos - (p)[0].cur_start] \
- : CORD__pos_fetch(p))
+ (p)[0].cur_leaf[(p)[0].cur_pos - (p)[0].cur_start] \
+ : CORD__pos_fetch(p))
-#define CORD_next(p) \
+#define CORD_next(p) \
(((p)[0].cur_pos + 1 < (p)[0].cur_end)? \
- (p)[0].cur_pos++ \
- : (CORD__next(p), 0))
+ (p)[0].cur_pos++ \
+ : (CORD__next(p), 0))
-#define CORD_prev(p) \
+#define CORD_prev(p) \
(((p)[0].cur_end != 0 && (p)[0].cur_pos > (p)[0].cur_start)? \
- (p)[0].cur_pos-- \
- : (CORD__prev(p), 0))
+ (p)[0].cur_pos-- \
+ : (CORD__prev(p), 0))
#define CORD_pos_to_index(p) ((p)[0].cur_pos)
#define CORD_pos_valid(p) ((p)[0].path_len != CORD_POS_INVALID)
-/* Some grubby stuff for performance-critical friends: */
+/* Some grubby stuff for performance-critical friends: */
#define CORD_pos_chars_left(p) ((long)((p)[0].cur_end) - (long)((p)[0].cur_pos))
- /* Number of characters in cache. <= 0 ==> none */
+ /* Number of characters in cache. <= 0 ==> none */
#define CORD_pos_advance(p,n) ((p)[0].cur_pos += (n) - 1, CORD_next(p))
- /* Advance position by n characters */
- /* 0 < n < CORD_pos_chars_left(p) */
+ /* Advance position by n characters */
+ /* 0 < n < CORD_pos_chars_left(p) */
#define CORD_pos_cur_char_addr(p) \
- (p)[0].cur_leaf + ((p)[0].cur_pos - (p)[0].cur_start)
- /* address of current character in cache. */
+ (p)[0].cur_leaf + ((p)[0].cur_pos - (p)[0].cur_start)
+ /* address of current character in cache. */
#endif
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, July 11, 1995 11:54 am PDT */
+
#ifndef GC_HEADERS_H
#define GC_HEADERS_H
/* h. Assumes hhdr == HDR(h) and IS_FORWARDING_ADDR(hhdr). */
#define FORWARDED_ADDR(h, hhdr) ((struct hblk *)(h) - (size_t)(hhdr))
-#endif /* GC_HEADERS_H */
+#endif /* GC_HEADERS_H */
-#ifndef _weakpointer_h_
-#define _weakpointer_h_
+#ifndef _weakpointer_h_
+#define _weakpointer_h_
/****************************************************************************
Permission is hereby granted to copy this code for any purpose,
provided the above notices are retained on all copies.
- Last modified on Mon Jul 17 18:16:01 PDT 1995 by ellis
-
****************************************************************************/
/****************************************************************************
and d can be null, but t cannot. Sets the clean-up queue for
BO(t) to be the collector's queue. When t is removed from its
clean-up queue, its clean-up will be applied by calling c(d,
- t). It is an error if *t is not a collected object. */
+ t). It is an error if *t is not a collected object. */
{_CleanUp_Set( t, c, d );}
static void Call( T* t )
}
#endif /* _weakpointer_h_ */
-
-
-#
-#
+#
# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
# OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
-#
+#
# Permission is hereby granted to use or copy this program
# for any purpose, provided the above notices are retained on all copies.
# Permission to modify the code and to distribute modified code is granted,
# provided the above notices are retained, and a notice that the code was
# modified is included with the above copyright notice.
-#
-# Modified by: Grzegorz Jakacki <jakacki at acm dot org>
# GC_SET_VERSION
# sets and AC_DEFINEs GC_VERSION_MAJOR, GC_VERSION_MINOR and GC_ALPHA_VERSION
# based on the contents of PACKAGE_VERSION; PACKAGE_VERSION must conform to
-# [0-9]+[.][0-9]+(alpha[0.9]+)?
+# [0-9]+[.][0-9]+(alpha[0.9]+)?
# in lex syntax; if there is no alpha number, GC_ALPHA_VERSION is empty
#
AC_DEFUN([GC_SET_VERSION], [
GC_ALPHA_VERSION=`echo $PACKAGE_VERSION | sed 's/^[[^.]]*[[.]][[0-9]]*//'`
case "$GC_ALPHA_VERSION" in
- alpha*)
+ alpha*)
GC_ALPHA_VERSION=`echo $GC_ALPHA_VERSION \
| sed 's/alpha\([[0-9]][[0-9]]*\)/\1/'` ;;
*) GC_ALPHA_MAJOR='' ;;
AC_MSG_RESULT(invalid)
AC_MSG_ERROR([nonconforming PACKAGE_VERSION='$PACKAGE_VERSION'])
fi
-
+
AC_DEFINE_UNQUOTED([GC_VERSION_MAJOR], $GC_VERSION_MAJOR,
- [The major version number of this GC release.])
+ [The major version number of this GC release.])
AC_DEFINE_UNQUOTED([GC_VERSION_MINOR], $GC_VERSION_MINOR,
- [The minor version number of this GC release.])
+ [The minor version number of this GC release.])
if test :$GC_ALPHA_VERSION: != :: ; then
AC_DEFINE_UNQUOTED([GC_ALPHA_VERSION], $GC_ALPHA_VERSION,
- [The alpha version number, if applicable.])
+ [The alpha version number, if applicable.])
fi
AC_MSG_RESULT(major=$GC_VERSION_MAJOR minor=$GC_VERSION_MINOR \
${GC_ALPHA_VERSION:+alpha=}$GC_ALPHA_VERSION)
granted, provided the above notices are retained, and a notice that
the code was modified is included with the above copyright notice.
****************************************************************************
-Last modified on Mon Jul 10 21:06:03 PDT 1995 by ellis
- modified on December 20, 1994 7:27 pm PST by boehm
usage: test_cpp number-of-iterations
GC_printf( "The test appears to have succeeded.\n" );
return( 0 );
}
-